Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563642 views
1
2
D The subpackage ResidueClassRingForHomalg as a sample ring package
3
4
5
D.1 The Mandatory Basic Operations
6
7
D.1-1 BasisOfRowModule
8
9
BasisOfRowModule( M )  function
10
Returns: a homalg matrix over the ambient ring
11
12
 Code 
13
BasisOfRowModule :=
14
 function( M )
15
 local Mrel;
16
 
17
 Mrel := UnionOfRows( M );
18
 
19
 Mrel := HomalgResidueClassMatrix(
20
 BasisOfRowModule( Mrel ), HomalgRing( M ) );
21
 
22
 return GetRidOfObsoleteRows( Mrel );
23
 
24
 end,
25

26
27
D.1-2 BasisOfColumnModule
28
29
BasisOfColumnModule( M )  function
30
Returns: a homalg matrix over the ambient ring
31
32
 Code 
33
BasisOfColumnModule :=
34
 function( M )
35
 local Mrel;
36
 
37
 Mrel := UnionOfColumns( M );
38
 
39
 Mrel := HomalgResidueClassMatrix(
40
 BasisOfColumnModule( Mrel ), HomalgRing( M ) );
41
 
42
 return GetRidOfObsoleteColumns( Mrel );
43
 
44
 end,
45

46
47
D.1-3 DecideZeroRows
48
49
DecideZeroRows( A, B )  function
50
Returns: a homalg matrix over the ambient ring
51
52
 Code 
53
DecideZeroRows :=
54
 function( A, B )
55
 local Brel;
56
 
57
 Brel := UnionOfRows( B );
58
 
59
 Brel := BasisOfRowModule( Brel );
60
 
61
 return HomalgResidueClassMatrix(
62
 DecideZeroRows( Eval( A ), Brel ), HomalgRing( A ) );
63
 
64
 end,
65

66
67
D.1-4 DecideZeroColumns
68
69
DecideZeroColumns( A, B )  function
70
Returns: a homalg matrix over the ambient ring
71
72
 Code 
73
DecideZeroColumns :=
74
 function( A, B )
75
 local Brel;
76
 
77
 Brel := UnionOfColumns( B );
78
 
79
 Brel := BasisOfColumnModule( Brel );
80
 
81
 return HomalgResidueClassMatrix(
82
 DecideZeroColumns( Eval( A ), Brel ), HomalgRing( A ) );
83
 
84
 end,
85

86
87
D.1-5 SyzygiesGeneratorsOfRows
88
89
SyzygiesGeneratorsOfRows( M )  function
90
Returns: a homalg matrix over the ambient ring
91
92
 Code 
93
SyzygiesGeneratorsOfRows :=
94
 function( M )
95
 local R, ring_rel, rel, S;
96
 
97
 R := HomalgRing( M );
98
 
99
 ring_rel := RingRelations( R );
100
 
101
 rel := MatrixOfRelations( ring_rel );
102
 
103
 if IsHomalgRingRelationsAsGeneratorsOfRightIdeal( ring_rel ) then
104
 rel := Involution( rel );
105
 fi;
106
 
107
 rel := DiagMat( ListWithIdenticalEntries( NrColumns( M ), rel ) );
108
 
109
 S := SyzygiesGeneratorsOfRows( Eval( M ), rel );
110
 
111
 S := HomalgResidueClassMatrix( S, R );
112
 
113
 S := GetRidOfObsoleteRows( S );
114
 
115
 if IsZero( S ) then
116
 
117
 SetIsLeftRegular( M, true );
118
 
119
 fi;
120
 
121
 return S;
122
 
123
 end,
124

125
126
D.1-6 SyzygiesGeneratorsOfColumns
127
128
SyzygiesGeneratorsOfColumns( M )  function
129
Returns: a homalg matrix over the ambient ring
130
131
 Code 
132
SyzygiesGeneratorsOfColumns :=
133
 function( M )
134
 local R, ring_rel, rel, S;
135
 
136
 R := HomalgRing( M );
137
 
138
 ring_rel := RingRelations( R );
139
 
140
 rel := MatrixOfRelations( ring_rel );
141
 
142
 if IsHomalgRingRelationsAsGeneratorsOfLeftIdeal( ring_rel ) then
143
 rel := Involution( rel );
144
 fi;
145
 
146
 rel := DiagMat( ListWithIdenticalEntries( NrRows( M ), rel ) );
147
 
148
 S := SyzygiesGeneratorsOfColumns( Eval( M ), rel );
149
 
150
 S := HomalgResidueClassMatrix( S, R );
151
 
152
 S := GetRidOfObsoleteColumns( S );
153
 
154
 if IsZero( S ) then
155
 
156
 SetIsRightRegular( M, true );
157
 
158
 fi;
159
 
160
 return S;
161
 
162
 end,
163

164
165
D.1-7 BasisOfRowsCoeff
166
167
BasisOfRowsCoeff( M, T )  function
168
Returns: a homalg matrix over the ambient ring
169
170
 Code 
171
BasisOfRowsCoeff :=
172
 function( M, T )
173
 local Mrel, TT, bas, nz;
174
 
175
 Mrel := UnionOfRows( M );
176
 
177
 TT := HomalgVoidMatrix( HomalgRing( Mrel ) );
178
 
179
 bas := BasisOfRowsCoeff( Mrel, TT );
180
 
181
 bas := HomalgResidueClassMatrix( bas, HomalgRing( M ) );
182
 
183
 nz := NonZeroRows( bas );
184
 
185
 SetEval( T, CertainRows( CertainColumns( TT, [ 1 .. NrRows( M ) ] ), nz ) );
186
 
187
 ResetFilterObj( T, IsVoidMatrix );
188
 
189
 ## the generic BasisOfRowsCoeff will assume that
190
 ## ( NrRows( B ) = 0 ) = IsZero( B )
191
 return CertainRows( bas, nz );
192
 
193
 end,
194

195
196
D.1-8 BasisOfColumnsCoeff
197
198
BasisOfColumnsCoeff( M, T )  function
199
Returns: a homalg matrix over the ambient ring
200
201
 Code 
202
BasisOfColumnsCoeff :=
203
 function( M, T )
204
 local Mrel, TT, bas, nz;
205
 
206
 Mrel := UnionOfColumns( M );
207
 
208
 TT := HomalgVoidMatrix( HomalgRing( Mrel ) );
209
 
210
 bas := BasisOfColumnsCoeff( Mrel, TT );
211
 
212
 bas := HomalgResidueClassMatrix( bas, HomalgRing( M ) );
213
 
214
 nz := NonZeroColumns( bas );
215
 
216
 SetEval( T, CertainColumns( CertainRows( TT, [ 1 .. NrColumns( M ) ] ), nz ) );
217
 
218
 ResetFilterObj( T, IsVoidMatrix );
219
 
220
 ## the generic BasisOfColumnsCoeff will assume that
221
 ## ( NrColumns( B ) = 0 ) = IsZero( B )
222
 return CertainColumns( bas, nz );
223
 
224
 end,
225

226
227
D.1-9 DecideZeroRowsEffectively
228
229
DecideZeroRowsEffectively( A, B, T )  function
230
Returns: a homalg matrix over the ambient ring
231
232
 Code 
233
DecideZeroRowsEffectively :=
234
 function( A, B, T )
235
 local Brel, TT, red;
236
 
237
 Brel := UnionOfRows( B );
238
 
239
 TT := HomalgVoidMatrix( HomalgRing( Brel ) );
240
 
241
 red := DecideZeroRowsEffectively( Eval( A ), Brel, TT );
242
 
243
 SetEval( T, CertainColumns( TT, [ 1 .. NrRows( B ) ] ) );
244
 
245
 ResetFilterObj( T, IsVoidMatrix );
246
 
247
 return HomalgResidueClassMatrix( red, HomalgRing( A ) );
248
 
249
 end,
250

251
252
D.1-10 DecideZeroColumnsEffectively
253
254
DecideZeroColumnsEffectively( A, B, T )  function
255
Returns: a homalg matrix over the ambient ring
256
257
 Code 
258
DecideZeroColumnsEffectively :=
259
 function( A, B, T )
260
 local Brel, TT, red;
261
 
262
 Brel := UnionOfColumns( B );
263
 
264
 TT := HomalgVoidMatrix( HomalgRing( Brel ) );
265
 
266
 red := DecideZeroColumnsEffectively( Eval( A ), Brel, TT );
267
 
268
 SetEval( T, CertainRows( TT, [ 1 .. NrColumns( B ) ] ) );
269
 
270
 ResetFilterObj( T, IsVoidMatrix );
271
 
272
 return HomalgResidueClassMatrix( red, HomalgRing( A ) );
273
 
274
 end,
275

276
277
D.1-11 RelativeSyzygiesGeneratorsOfRows
278
279
RelativeSyzygiesGeneratorsOfRows( M, M2 )  function
280
Returns: a homalg matrix over the ambient ring
281
282
 Code 
283
RelativeSyzygiesGeneratorsOfRows :=
284
 function( M, M2 )
285
 local M2rel, S;
286
 
287
 M2rel := UnionOfRows( M2 );
288
 
289
 S := SyzygiesGeneratorsOfRows( Eval( M ), M2rel );
290
 
291
 S := HomalgResidueClassMatrix( S, HomalgRing( M ) );
292
 
293
 S := GetRidOfObsoleteRows( S );
294
 
295
 if IsZero( S ) then
296
 
297
 SetIsLeftRegular( M, true );
298
 
299
 fi;
300
 
301
 return S;
302
 
303
 end,
304

305
306
D.1-12 RelativeSyzygiesGeneratorsOfColumns
307
308
RelativeSyzygiesGeneratorsOfColumns( M, M2 )  function
309
Returns: a homalg matrix over the ambient ring
310
311
 Code 
312
RelativeSyzygiesGeneratorsOfColumns :=
313
 function( M, M2 )
314
 local M2rel, S;
315
 
316
 M2rel := UnionOfColumns( M2 );
317
 
318
 S := SyzygiesGeneratorsOfColumns( Eval( M ), M2rel );
319
 
320
 S := HomalgResidueClassMatrix( S, HomalgRing( M ) );
321
 
322
 S := GetRidOfObsoleteColumns( S );
323
 
324
 if IsZero( S ) then
325
 
326
 SetIsRightRegular( M, true );
327
 
328
 fi;
329
 
330
 return S;
331
 
332
 end,
333

334
335
336
D.2 The Mandatory Tool Operations
337
338
Here we list those matrix operations for which homalg provides no fallback
339
method.
340
341
D.2-1 InitialMatrix
342
343
InitialMatrix( )  function
344
Returns: a homalg matrix over the ambient ring
345
346
(--> InitialMatrix (B.1-1))
347
348
 Code 
349
InitialMatrix := C -> HomalgInitialMatrix(
350
 NrRows( C ), NrColumns( C ), AmbientRing( HomalgRing( C ) ) ),
351

352
353
D.2-2 InitialIdentityMatrix
354
355
InitialIdentityMatrix( )  function
356
Returns: a homalg matrix over the ambient ring
357
358
(--> InitialIdentityMatrix (B.1-2))
359
360
 Code 
361
InitialIdentityMatrix := C -> HomalgInitialIdentityMatrix(
362
 NrRows( C ), AmbientRing( HomalgRing( C ) ) ),
363

364
365
D.2-3 ZeroMatrix
366
367
ZeroMatrix( )  function
368
Returns: a homalg matrix over the ambient ring
369
370
(--> ZeroMatrix (B.1-3))
371
372
 Code 
373
ZeroMatrix := C -> HomalgZeroMatrix(
374
 NrRows( C ), NrColumns( C ), AmbientRing( HomalgRing( C ) ) ),
375

376
377
D.2-4 IdentityMatrix
378
379
IdentityMatrix( )  function
380
Returns: a homalg matrix over the ambient ring
381
382
(--> IdentityMatrix (B.1-4))
383
384
 Code 
385
IdentityMatrix := C -> HomalgIdentityMatrix(
386
 NrRows( C ), AmbientRing( HomalgRing( C ) ) ),
387

388
389
D.2-5 Involution
390
391
Involution( )  function
392
Returns: a homalg matrix over the ambient ring
393
394
(--> Involution (B.1-5))
395
396
 Code 
397
Involution :=
398
 function( M )
399
 local N, R;
400
 
401
 N := Involution( Eval( M ) );
402
 
403
 R := HomalgRing( N );
404
 
405
 if not ( HasIsCommutative( R ) and IsCommutative( R ) and
406
 HasIsReducedModuloRingRelations( M ) and
407
 IsReducedModuloRingRelations( M ) ) then
408
 
409
 ## reduce the matrix N w.r.t. the ring relations
410
 N := DecideZero( N, HomalgRing( M ) );
411
 fi;
412
 
413
 return N;
414
 
415
 end,
416

417
418
D.2-6 CertainRows
419
420
CertainRows( )  function
421
Returns: a homalg matrix over the ambient ring
422
423
(--> CertainRows (B.1-6))
424
425
 Code 
426
CertainRows :=
427
 function( M, plist )
428
 local N;
429
 
430
 N := CertainRows( Eval( M ), plist );
431
 
432
 if not ( HasIsReducedModuloRingRelations( M ) and
433
 IsReducedModuloRingRelations( M ) ) then
434
 
435
 ## reduce the matrix N w.r.t. the ring relations
436
 N := DecideZero( N, HomalgRing( M ) );
437
 fi;
438
 
439
 return N;
440
 
441
 end,
442

443
444
D.2-7 CertainColumns
445
446
CertainColumns( )  function
447
Returns: a homalg matrix over the ambient ring
448
449
(--> CertainColumns (B.1-7))
450
451
 Code 
452
CertainColumns :=
453
 function( M, plist )
454
 local N;
455
 
456
 N := CertainColumns( Eval( M ), plist );
457
 
458
 if not ( HasIsReducedModuloRingRelations( M ) and
459
 IsReducedModuloRingRelations( M ) ) then
460
 
461
 ## reduce the matrix N w.r.t. the ring relations
462
 N := DecideZero( N, HomalgRing( M ) );
463
 fi;
464
 
465
 return N;
466
 
467
 end,
468

469
470
D.2-8 UnionOfRows
471
472
UnionOfRows( )  function
473
Returns: a homalg matrix over the ambient ring
474
475
(--> UnionOfRows (B.1-8))
476
477
 Code 
478
UnionOfRows :=
479
 function( A, B )
480
 local N;
481
 
482
 N := UnionOfRows( Eval( A ), Eval( B ) );
483
 
484
 if not ForAll( [ A, B ], HasIsReducedModuloRingRelations and
485
 IsReducedModuloRingRelations ) then
486
 
487
 ## reduce the matrix N w.r.t. the ring relations
488
 N := DecideZero( N, HomalgRing( A ) );
489
 fi;
490
 
491
 return N;
492
 
493
 end,
494

495
496
D.2-9 UnionOfColumns
497
498
UnionOfColumns( )  function
499
Returns: a homalg matrix over the ambient ring
500
501
(--> UnionOfColumns (B.1-9))
502
503
 Code 
504
UnionOfColumns :=
505
 function( A, B )
506
 local N;
507
 
508
 N := UnionOfColumns( Eval( A ), Eval( B ) );
509
 
510
 if not ForAll( [ A, B ], HasIsReducedModuloRingRelations and
511
 IsReducedModuloRingRelations ) then
512
 
513
 ## reduce the matrix N w.r.t. the ring relations
514
 N := DecideZero( N, HomalgRing( A ) );
515
 fi;
516
 
517
 return N;
518
 
519
 end,
520

521
522
D.2-10 DiagMat
523
524
DiagMat( )  function
525
Returns: a homalg matrix over the ambient ring
526
527
(--> DiagMat (B.1-10))
528
529
 Code 
530
DiagMat :=
531
 function( e )
532
 local N;
533
 
534
 N := DiagMat( List( e, Eval ) );
535
 
536
 if not ForAll( e, HasIsReducedModuloRingRelations and
537
 IsReducedModuloRingRelations ) then
538
 
539
 ## reduce the matrix N w.r.t. the ring relations
540
 N := DecideZero( N, HomalgRing( e[1] ) );
541
 fi;
542
 
543
 return N;
544
 
545
 end,
546

547
548
D.2-11 KroneckerMat
549
550
KroneckerMat( )  function
551
Returns: a homalg matrix over the ambient ring
552
553
(--> KroneckerMat (B.1-11))
554
555
 Code 
556
KroneckerMat :=
557
 function( A, B )
558
 local N;
559
 
560
 N := KroneckerMat( Eval( A ), Eval( B ) );
561
 
562
 if not ForAll( [ A, B ], HasIsReducedModuloRingRelations and
563
 IsReducedModuloRingRelations ) then
564
 
565
 ## reduce the matrix N w.r.t. the ring relations
566
 N := DecideZero( N, HomalgRing( A ) );
567
 fi;
568
 
569
 return N;
570
 
571
 end,
572

573
574
D.2-12 MulMat
575
576
MulMat( )  function
577
Returns: a homalg matrix over the ambient ring
578
579
(--> MulMat (B.1-12))
580
581
 Code 
582
MulMat :=
583
 function( a, A )
584
 
585
 return DecideZero( EvalRingElement( a ) * Eval( A ), HomalgRing( A ) );
586
 
587
 end,
588
MulMatRight :=
589
 function( A, a )
590
 
591
 return DecideZero( Eval( A ) * EvalRingElement( a ), HomalgRing( A ) );
592
 
593
 end,
594

595
596
D.2-13 AddMat
597
598
AddMat( )  function
599
Returns: a homalg matrix over the ambient ring
600
601
(--> AddMat (B.1-13))
602
603
 Code 
604
AddMat :=
605
 function( A, B )
606
 
607
 return DecideZero( Eval( A ) + Eval( B ), HomalgRing( A ) );
608
 
609
 end,
610

611
612
D.2-14 SubMat
613
614
SubMat( )  function
615
Returns: a homalg matrix over the ambient ring
616
617
(--> SubMat (B.1-14))
618
619
 Code 
620
SubMat :=
621
 function( A, B )
622
 
623
 return DecideZero( Eval( A ) - Eval( B ), HomalgRing( A ) );
624
 
625
 end,
626

627
628
D.2-15 Compose
629
630
Compose( )  function
631
Returns: a homalg matrix over the ambient ring
632
633
(--> Compose (B.1-15))
634
635
 Code 
636
Compose :=
637
 function( A, B )
638
 
639
 return DecideZero( Eval( A ) * Eval( B ), HomalgRing( A ) );
640
 
641
 end,
642

643
644
D.2-16 IsZeroMatrix
645
646
IsZeroMatrix( M )  function
647
Returns: true or false
648
649
(--> IsZeroMatrix (B.1-16))
650
651
 Code 
652
IsZeroMatrix := M -> IsZero( DecideZero( Eval( M ), HomalgRing( M ) ) ),
653

654
655
D.2-17 NrRows
656
657
NrRows( C )  function
658
Returns: a nonnegative integer
659
660
(--> NrRows (B.1-17))
661
662
 Code 
663
NrRows := C -> NrRows( Eval( C ) ),
664

665
666
D.2-18 NrColumns
667
668
NrColumns( C )  function
669
Returns: a nonnegative integer
670
671
(--> NrColumns (B.1-18))
672
673
 Code 
674
NrColumns := C -> NrColumns( Eval( C ) ),
675

676
677
D.2-19 Determinant
678
679
Determinant( C )  function
680
Returns: an element of ambient homalg ring
681
682
(--> Determinant (B.1-19))
683
684
 Code 
685
Determinant := C -> DecideZero( Determinant( Eval( C ) ), HomalgRing( C ) ),
686

687
688
689
D.3 Some of the Recommended Tool Operations
690
691
Here we list those matrix operations for which homalg does provide a
692
fallback method. But specifying the below homalgTable functions increases
693
the performance by replacing the fallback method.
694
695
D.3-1 AreEqualMatrices
696
697
AreEqualMatrices( A, B )  function
698
Returns: true or false
699
700
(--> AreEqualMatrices (B.2-1))
701
702
 Code 
703
AreEqualMatrices :=
704
 function( A, B )
705
 
706
 return IsZero( DecideZero( Eval( A ) - Eval( B ), HomalgRing( A ) ) );
707
 
708
 end,
709

710
711
D.3-2 IsOne
712
713
IsOne( M )  function
714
Returns: true or false
715
716
(--> IsIdentityMatrix (B.2-2))
717
718
 Code 
719
IsIdentityMatrix := M ->
720
 IsOne( DecideZero( Eval( M ), HomalgRing( M ) ) ),
721

722
723
D.3-3 IsDiagonalMatrix
724
725
IsDiagonalMatrix( M )  function
726
Returns: true or false
727
728
(--> IsDiagonalMatrix (B.2-3))
729
730
 Code 
731
IsDiagonalMatrix := M ->
732
 IsDiagonalMatrix( DecideZero( Eval( M ), HomalgRing( M ) ) ),
733

734
735
D.3-4 ZeroRows
736
737
ZeroRows( C )  function
738
Returns: a homalg matrix over the ambient ring
739
740
(--> ZeroRows (B.2-4))
741
742
 Code 
743
ZeroRows := C -> ZeroRows( DecideZero( Eval( C ), HomalgRing( C ) ) ),
744

745
746
D.3-5 ZeroColumns
747
748
ZeroColumns( C )  function
749
Returns: a homalg matrix over the ambient ring
750
751
(--> ZeroColumns (B.2-5))
752
753
 Code 
754
ZeroColumns := C -> ZeroColumns( DecideZero( Eval( C ), HomalgRing( C ) ) ),
755

756
757
758