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

563574 views
1
2
5 Matrices
3
4
5
5.1 Matrices: Category and Representations
6
7
5.1-1 IsHomalgMatrix
8
9
IsHomalgMatrix( A )  Category
10
Returns: true or false
11
12
The GAP category of homalg matrices.
13
14
 Code 
15
DeclareCategory( "IsHomalgMatrix",
16
 IsMatrixObj and
17
 IsAttributeStoringRep );
18

19
20
5.1-2 IsHomalgInternalMatrixRep
21
22
IsHomalgInternalMatrixRep( A )  Representation
23
Returns: true or false
24
25
The internal representation of homalg matrices.
26
27
(It is a representation of the GAP category IsHomalgMatrix (5.1-1).)
28
29
30
5.2 Matrices: Constructors
31
32
5.2-1 HomalgInitialMatrix
33
34
HomalgInitialMatrix( m, n, R )  function
35
Returns: a homalg matrix
36
37
A mutable unevaluated initial m × n homalg matrix filled with zeros over the
38
homalg ring R. This construction is useful in case one wants to define a
39
matrix by assigning its nonzero entries. The property IsInitialMatrix
40
(5.3-26) is reset as soon as the matrix is evaluated. New computed
41
properties or attributes of the matrix won't be cached, until the matrix is
42
explicitly made immutable using (--> MakeImmutable (Reference:
43
MakeImmutable)).
44
45
 Example 
46
gap> ZZ := HomalgRingOfIntegers( );
47
Z
48
gap> z := HomalgInitialMatrix( 2, 3, ZZ );
49
<An initial 2 x 3 matrix over an internal ring>
50
gap> HasIsZero( z );
51
false
52
gap> IsZero( z );
53
true
54
gap> z;
55
<A 2 x 3 mutable matrix over an internal ring>
56
gap> HasIsZero( z );
57
false
58

59
60
 Example 
61
gap> n := HomalgInitialMatrix( 2, 3, ZZ );
62
<An initial 2 x 3 matrix over an internal ring>
63
gap> SetMatElm( n, 1, 1, "1" );
64
gap> SetMatElm( n, 2, 3, "1" );
65
gap> MakeImmutable( n );
66
<A 2 x 3 matrix over an internal ring>
67
gap> Display( n );
68
[ [ 1, 0, 0 ],
69
 [ 0, 0, 1 ] ]
70
gap> IsZero( n );
71
false
72
gap> n;
73
<A non-zero 2 x 3 matrix over an internal ring>
74

75
76
5.2-2 HomalgInitialIdentityMatrix
77
78
HomalgInitialIdentityMatrix( m, R )  function
79
Returns: a homalg matrix
80
81
A mutable unevaluated initial m × m homalg quadratic matrix with ones on the
82
diagonal over the homalg ring R. This construction is useful in case one
83
wants to define an elementary matrix by assigning its off-diagonal nonzero
84
entries. The property IsInitialIdentityMatrix (5.3-27) is reset as soon as
85
the matrix is evaluated. New computed properties or attributes of the matrix
86
won't be cached, until the matrix is explicitly made immutable using (-->
87
MakeImmutable (Reference: MakeImmutable)).
88
89
 Example 
90
gap> ZZ := HomalgRingOfIntegers( );
91
Z
92
gap> id := HomalgInitialIdentityMatrix( 3, ZZ );
93
<An initial identity 3 x 3 matrix over an internal ring>
94
gap> HasIsOne( id );
95
false
96
gap> IsOne( id );
97
true
98
gap> id;
99
<A 3 x 3 mutable matrix over an internal ring>
100
gap> HasIsOne( id );
101
false
102

103
104
 Example 
105
gap> e := HomalgInitialIdentityMatrix( 3, ZZ );
106
<An initial identity 3 x 3 matrix over an internal ring>
107
gap> SetMatElm( e, 1, 2, "1" );
108
gap> SetMatElm( e, 2, 1, "-1" );
109
gap> MakeImmutable( e );
110
<A 3 x 3 matrix over an internal ring>
111
gap> Display( e );
112
[ [ 1, 1, 0 ],
113
 [ -1, 1, 0 ],
114
 [ 0, 0, 1 ] ]
115
gap> IsOne( e );
116
false
117
gap> e;
118
<A 3 x 3 matrix over an internal ring>
119

120
121
5.2-3 HomalgZeroMatrix
122
123
HomalgZeroMatrix( m, n, R )  function
124
Returns: a homalg matrix
125
126
An immutable unevaluated m × n homalg zero matrix over the homalg ring R.
127
128
 Example 
129
gap> ZZ := HomalgRingOfIntegers( );
130
Z
131
gap> z := HomalgZeroMatrix( 2, 3, ZZ );
132
<An unevaluated 2 x 3 zero matrix over an internal ring>
133
gap> Display( z );
134
[ [ 0, 0, 0 ],
135
 [ 0, 0, 0 ] ]
136
gap> z;
137
<A 2 x 3 zero matrix over an internal ring>
138

139
140
5.2-4 HomalgIdentityMatrix
141
142
HomalgIdentityMatrix( m, R )  function
143
Returns: a homalg matrix
144
145
An immutable unevaluated m × m homalg identity matrix over the homalg ring
146
R.
147
148
 Example 
149
gap> ZZ := HomalgRingOfIntegers( );
150
Z
151
gap> id := HomalgIdentityMatrix( 3, ZZ );
152
<An unevaluated 3 x 3 identity matrix over an internal ring>
153
gap> Display( id );
154
[ [ 1, 0, 0 ],
155
 [ 0, 1, 0 ],
156
 [ 0, 0, 1 ] ]
157
gap> id;
158
<A 3 x 3 identity matrix over an internal ring>
159

160
161
5.2-5 HomalgVoidMatrix
162
163
HomalgVoidMatrix( [m, ][n, ]R )  function
164
Returns: a homalg matrix
165
166
A void m × n homalg matrix.
167
168
5.2-6 HomalgMatrix
169
170
HomalgMatrix( llist, R )  function
171
HomalgMatrix( list, m, n, R )  function
172
HomalgMatrix( str_llist, R )  function
173
HomalgMatrix( str_list, m, n, R )  function
174
Returns: a homalg matrix
175
176
An immutable evaluated m × n homalg matrix over the homalg ring R.
177
178
 Example 
179
gap> ZZ := HomalgRingOfIntegers( );
180
Z
181
gap> m := HomalgMatrix( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ], ZZ );
182
<A 2 x 3 matrix over an internal ring>
183
gap> Display( m );
184
[ [ 1, 2, 3 ],
185
 [ 4, 5, 6 ] ]
186

187
188
 Example 
189
gap> m := HomalgMatrix( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ], 2, 3, ZZ );
190
<A 2 x 3 matrix over an internal ring>
191
gap> Display( m );
192
[ [ 1, 2, 3 ],
193
 [ 4, 5, 6 ] ]
194

195
196
 Example 
197
gap> m := HomalgMatrix( [ 1, 2, 3, 4, 5, 6 ], 2, 3, ZZ );
198
<A 2 x 3 matrix over an internal ring>
199
gap> Display( m );
200
[ [ 1, 2, 3 ],
201
 [ 4, 5, 6 ] ]
202

203
204
 Example 
205
gap> m := HomalgMatrix( "[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]", ZZ );
206
<A 2 x 3 matrix over an internal ring>
207
gap> Display( m );
208
[ [ 1, 2, 3 ],
209
 [ 4, 5, 6 ] ]
210

211
212
 Example 
213
gap> m := HomalgMatrix( "[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]", 2, 3, ZZ );
214
<A 2 x 3 matrix over an internal ring>
215
gap> Display( m );
216
[ [ 1, 2, 3 ],
217
 [ 4, 5, 6 ] ]
218

219
220
It is nevertheless recommended to use the following form to create homalg
221
matrices. This form can also be used to define external matrices. Since
222
whitespaces (--> Reference: Whitespaces) are ignored, they can be used as
223
optical delimiters:
224
225
 Example 
226
gap> m := HomalgMatrix( "[ 1, 2, 3, 4, 5, 6 ]", 2, 3, ZZ );
227
<A 2 x 3 matrix over an internal ring>
228
gap> Display( m );
229
[ [ 1, 2, 3 ],
230
 [ 4, 5, 6 ] ]
231

232
233
One can split the input string over several lines using the backslash
234
character '\' to end each line
235
236
 Example 
237
gap> m := HomalgMatrix( "[ \
238
> 1, 2, 3, \
239
> 4, 5, 6 \
240
> ]", 2, 3, ZZ );
241
<A 2 x 3 matrix over an internal ring>
242
gap> Display( m );
243
[ [ 1, 2, 3 ],
244
 [ 4, 5, 6 ] ]
245

246
247
5.2-7 HomalgDiagonalMatrix
248
249
HomalgDiagonalMatrix( diag, R )  function
250
Returns: a homalg matrix
251
252
An immutable unevaluated diagonal homalg matrix over the homalg ring R. The
253
diagonal consists of the entries of the list diag.
254
255
 Example 
256
gap> ZZ := HomalgRingOfIntegers( );
257
Z
258
gap> d := HomalgDiagonalMatrix( [ 1, 2, 3 ], ZZ );
259
<An unevaluated diagonal 3 x 3 matrix over an internal ring>
260
gap> Display( d );
261
[ [ 1, 0, 0 ],
262
 [ 0, 2, 0 ],
263
 [ 0, 0, 3 ] ]
264
gap> d;
265
<A diagonal 3 x 3 matrix over an internal ring>
266

267
268
5.2-8 \*
269
270
\*( R, mat )  operation
271
\*( mat, R )  operation
272
Returns: a homalg matrix
273
274
An immutable evaluated homalg matrix over the homalg ring R having the same
275
entries as the matrix mat. Syntax: R * mat or mat * R
276
277
 Example 
278
gap> ZZ := HomalgRingOfIntegers( );
279
Z
280
gap> Z4 := ZZ / 4;
281
Z/( 4 )
282
gap> Display( Z4 );
283
<A residue class ring>
284
gap> d := HomalgDiagonalMatrix( [ 2 .. 4 ], ZZ );
285
<An unevaluated diagonal 3 x 3 matrix over an internal ring>
286
gap> d2 := Z4 * d; ## or d2 := d * Z4;
287
<A 3 x 3 matrix over a residue class ring>
288
gap> Display( d2 );
289
[ [ 2, 0, 0 ],
290
 [ 0, 3, 0 ],
291
 [ 0, 0, 4 ] ]
292

293
modulo [ 4 ]
294
gap> d;
295
<A diagonal 3 x 3 matrix over an internal ring>
296
gap> ZeroRows( d );
297
[ ]
298
gap> ZeroRows( d2 );
299
[ 3 ]
300
gap> d;
301
<A non-zero diagonal 3 x 3 matrix over an internal ring>
302
gap> d2;
303
<A non-zero 3 x 3 matrix over a residue class ring>
304

305
306
307
5.3 Matrices: Properties
308
309
5.3-1 IsZero
310
311
IsZero( A )  property
312
Returns: true or false
313
314
Check if the homalg matrix A is a zero matrix, taking possible ring
315
relations into account.
316
317
(for the installed standard method see IsZeroMatrix (B.1-16))
318
319
 Example 
320
gap> ZZ := HomalgRingOfIntegers( );
321
Z
322
gap> A := HomalgMatrix( "[ 2 ]", ZZ );
323
<A 1 x 1 matrix over an internal ring>
324
gap> Z2 := ZZ / 2;
325
Z/( 2 )
326
gap> A := Z2 * A;
327
<A 1 x 1 matrix over a residue class ring>
328
gap> Display( A );
329
[ [ 2 ] ]
330

331
modulo [ 2 ]
332
gap> IsZero( A );
333
true
334

335
336
5.3-2 IsOne
337
338
IsOne( A )  property
339
Returns: true or false
340
341
Check if the homalg matrix A is an identity matrix, taking possible ring
342
relations into account.
343
344
(for the installed standard method see IsIdentityMatrix (B.2-2))
345
346
5.3-3 IsUnitFree
347
348
IsUnitFree( A )  property
349
Returns: true or false
350
351
A is a homalg matrix.
352
353
5.3-4 IsPermutationMatrix
354
355
IsPermutationMatrix( A )  property
356
Returns: true or false
357
358
A is a homalg matrix.
359
360
5.3-5 IsSpecialSubidentityMatrix
361
362
IsSpecialSubidentityMatrix( A )  property
363
Returns: true or false
364
365
A is a homalg matrix.
366
367
5.3-6 IsSubidentityMatrix
368
369
IsSubidentityMatrix( A )  property
370
Returns: true or false
371
372
A is a homalg matrix.
373
374
5.3-7 IsLeftRegular
375
376
IsLeftRegular( A )  property
377
Returns: true or false
378
379
A is a homalg matrix.
380
381
5.3-8 IsRightRegular
382
383
IsRightRegular( A )  property
384
Returns: true or false
385
386
A is a homalg matrix.
387
388
5.3-9 IsInvertibleMatrix
389
390
IsInvertibleMatrix( A )  property
391
Returns: true or false
392
393
A is a homalg matrix.
394
395
5.3-10 IsLeftInvertibleMatrix
396
397
IsLeftInvertibleMatrix( A )  property
398
Returns: true or false
399
400
A is a homalg matrix.
401
402
5.3-11 IsRightInvertibleMatrix
403
404
IsRightInvertibleMatrix( A )  property
405
Returns: true or false
406
407
A is a homalg matrix.
408
409
5.3-12 IsEmptyMatrix
410
411
IsEmptyMatrix( A )  property
412
Returns: true or false
413
414
A is a homalg matrix.
415
416
5.3-13 IsDiagonalMatrix
417
418
IsDiagonalMatrix( A )  property
419
Returns: true or false
420
421
Check if the homalg matrix A is an identity matrix, taking possible ring
422
relations into account.
423
424
(for the installed standard method see IsDiagonalMatrix (B.2-3))
425
426
5.3-14 IsScalarlMatrix
427
428
IsScalarlMatrix( A )  property
429
Returns: true or false
430
431
A is a homalg matrix.
432
433
5.3-15 IsUpperTriangularMatrix
434
435
IsUpperTriangularMatrix( A )  property
436
Returns: true or false
437
438
A is a homalg matrix.
439
440
5.3-16 IsLowerTriangularMatrix
441
442
IsLowerTriangularMatrix( A )  property
443
Returns: true or false
444
445
A is a homalg matrix.
446
447
5.3-17 IsStrictUpperTriangularMatrix
448
449
IsStrictUpperTriangularMatrix( A )  property
450
Returns: true or false
451
452
A is a homalg matrix.
453
454
5.3-18 IsStrictLowerTriangularMatrix
455
456
IsStrictLowerTriangularMatrix( A )  property
457
Returns: true or false
458
459
A is a homalg matrix.
460
461
5.3-19 IsUpperStairCaseMatrix
462
463
IsUpperStairCaseMatrix( A )  property
464
Returns: true or false
465
466
A is a homalg matrix.
467
468
5.3-20 IsLowerStairCaseMatrix
469
470
IsLowerStairCaseMatrix( A )  property
471
Returns: true or false
472
473
A is a homalg matrix.
474
475
5.3-21 IsTriangularMatrix
476
477
IsTriangularMatrix( A )  property
478
Returns: true or false
479
480
A is a homalg matrix.
481
482
5.3-22 IsBasisOfRowsMatrix
483
484
IsBasisOfRowsMatrix( A )  property
485
Returns: true or false
486
487
A is a homalg matrix.
488
489
5.3-23 IsBasisOfColumnsMatrix
490
491
IsBasisOfColumnsMatrix( A )  property
492
Returns: true or false
493
494
A is a homalg matrix.
495
496
5.3-24 IsReducedBasisOfRowsMatrix
497
498
IsReducedBasisOfRowsMatrix( A )  property
499
Returns: true or false
500
501
A is a homalg matrix.
502
503
5.3-25 IsReducedBasisOfColumnsMatrix
504
505
IsReducedBasisOfColumnsMatrix( A )  property
506
Returns: true or false
507
508
A is a homalg matrix.
509
510
5.3-26 IsInitialMatrix
511
512
IsInitialMatrix( A )  property
513
Returns: true or false
514
515
A is a homalg matrix.
516
517
5.3-27 IsInitialIdentityMatrix
518
519
IsInitialIdentityMatrix( A )  property
520
Returns: true or false
521
522
A is a homalg matrix.
523
524
5.3-28 IsVoidMatrix
525
526
IsVoidMatrix( A )  property
527
Returns: true or false
528
529
A is a homalg matrix.
530
531
532
5.4 Matrices: Attributes
533
534
5.4-1 NrRows
535
536
NrRows( A )  attribute
537
Returns: a nonnegative integer
538
539
The number of rows of the matrix A.
540
541
(for the installed standard method see NrRows (B.1-17))
542
543
5.4-2 NrColumns
544
545
NrColumns( A )  attribute
546
Returns: a nonnegative integer
547
548
The number of columns of the matrix A.
549
550
(for the installed standard method see NrColumns (B.1-18))
551
552
5.4-3 DeterminantMat
553
554
DeterminantMat( A )  attribute
555
Returns: a ring element
556
557
The determinant of the quadratic matrix A.
558
559
You can invoke it with Determinant( A ).
560
561
(for the installed standard method see Determinant (B.1-19))
562
563
5.4-4 ZeroRows
564
565
ZeroRows( A )  attribute
566
Returns: a (possibly empty) list of positive integers
567
568
The list of zero rows of the matrix A.
569
570
(for the installed standard method see ZeroRows (B.2-4))
571
572
5.4-5 ZeroColumns
573
574
ZeroColumns( A )  attribute
575
Returns: a (possibly empty) list of positive integers
576
577
The list of zero columns of the matrix A.
578
579
(for the installed standard method see ZeroColumns (B.2-5))
580
581
5.4-6 NonZeroRows
582
583
NonZeroRows( A )  attribute
584
Returns: a (possibly empty) list of positive integers
585
586
The list of nonzero rows of the matrix A.
587
588
5.4-7 NonZeroColumns
589
590
NonZeroColumns( A )  attribute
591
Returns: a (possibly empty) list of positive integers
592
593
The list of nonzero columns of the matrix A.
594
595
5.4-8 PositionOfFirstNonZeroEntryPerRow
596
597
PositionOfFirstNonZeroEntryPerRow( A )  attribute
598
Returns: a list of nonnegative integers
599
600
The list of positions of the first nonzero entry per row of the matrix A,
601
else zero.
602
603
5.4-9 PositionOfFirstNonZeroEntryPerColumn
604
605
PositionOfFirstNonZeroEntryPerColumn( A )  attribute
606
Returns: a list of nonnegative integers
607
608
The list of positions of the first nonzero entry per column of the matrix A,
609
else zero.
610
611
5.4-10 RowRankOfMatrix
612
613
RowRankOfMatrix( A )  attribute
614
Returns: a nonnegative integer
615
616
The row rank of the matrix A.
617
618
5.4-11 ColumnRankOfMatrix
619
620
ColumnRankOfMatrix( A )  attribute
621
Returns: a nonnegative integer
622
623
The column rank of the matrix A.
624
625
5.4-12 LeftInverse
626
627
LeftInverse( M )  attribute
628
Returns: a homalg matrix
629
630
A left inverse C of the matrix M. If no left inverse exists then false is
631
returned. (--> RightDivide (5.5-45))
632
633
(for the installed standard method see LeftInverse (5.5-2))
634
635
5.4-13 RightInverse
636
637
RightInverse( M )  attribute
638
Returns: a homalg matrix
639
640
A right inverse C of the matrix M. If no right inverse exists then false is
641
returned. (--> LeftDivide (5.5-46))
642
643
(for the installed standard method see RightInverse (5.5-3))
644
645
5.4-14 CoefficientsOfUnreducedNumeratorOfHilbertPoincareSeries
646
647
CoefficientsOfUnreducedNumeratorOfHilbertPoincareSeries( A )  attribute
648
Returns: a list of integers
649
650
A is a homalg matrix (row convention).
651
652
5.4-15 CoefficientsOfNumeratorOfHilbertPoincareSeries
653
654
CoefficientsOfNumeratorOfHilbertPoincareSeries( A )  attribute
655
Returns: a list of integers
656
657
A is a homalg matrix (row convention).
658
659
5.4-16 UnreducedNumeratorOfHilbertPoincareSeries
660
661
UnreducedNumeratorOfHilbertPoincareSeries( A )  attribute
662
Returns: a univariate polynomial with rational coefficients
663
664
A is a homalg matrix (row convention).
665
666
5.4-17 NumeratorOfHilbertPoincareSeries
667
668
NumeratorOfHilbertPoincareSeries( A )  attribute
669
Returns: a univariate polynomial with rational coefficients
670
671
A is a homalg matrix (row convention).
672
673
5.4-18 HilbertPoincareSeries
674
675
HilbertPoincareSeries( A )  attribute
676
Returns: a univariate rational function with rational coefficients
677
678
A is a homalg matrix (row convention).
679
680
5.4-19 HilbertPolynomial
681
682
HilbertPolynomial( A )  attribute
683
Returns: a univariate polynomial with rational coefficients
684
685
A is a homalg matrix (row convention).
686
687
5.4-20 AffineDimension
688
689
AffineDimension( A )  attribute
690
Returns: a nonnegative integer
691
692
A is a homalg matrix (row convention).
693
694
5.4-21 AffineDegree
695
696
AffineDegree( A )  attribute
697
Returns: a nonnegative integer
698
699
A is a homalg matrix (row convention).
700
701
5.4-22 ProjectiveDegree
702
703
ProjectiveDegree( A )  attribute
704
Returns: a nonnegative integer
705
706
A is a homalg matrix (row convention).
707
708
5.4-23 ConstantTermOfHilbertPolynomialn
709
710
ConstantTermOfHilbertPolynomialn( A )  attribute
711
Returns: an integer
712
713
A is a homalg matrix (row convention).
714
715
5.4-24 MatrixOfSymbols
716
717
MatrixOfSymbols( A )  attribute
718
Returns: an integer
719
720
A is a homalg matrix.
721
722
723
5.5 Matrices: Operations and Functions
724
725
5.5-1 HomalgRing
726
727
HomalgRing( mat )  operation
728
Returns: a homalg ring
729
730
The homalg ring of the homalg matrix mat.
731
732
 Example 
733
gap> ZZ := HomalgRingOfIntegers( );
734
Z
735
gap> d := HomalgDiagonalMatrix( [ 2 .. 4 ], ZZ );
736
<An unevaluated diagonal 3 x 3 matrix over an internal ring>
737
gap> R := HomalgRing( d );
738
Z
739
gap> IsIdenticalObj( R, ZZ );
740
true
741

742
743
5.5-2 LeftInverse
744
745
LeftInverse( RI )  method
746
Returns: a homalg matrix or fail
747
748
The left inverse of the matrix RI. The lazy version of this operation is
749
LeftInverseLazy (5.5-4). (--> RightDivide (5.5-45))
750
751
 Code 
752
InstallMethod( LeftInverse,
753
 "for homalg matrices",
754
 [ IsHomalgMatrix ],
755
 
756
 function( RI )
757
 local Id, LI;
758
 
759
 Id := HomalgIdentityMatrix( NrColumns( RI ), HomalgRing( RI ) );
760
 
761
 LI := RightDivide( Id, RI ); ## ( cf. [BR08, Subsection 3.1.3] )
762
 
763
 ## CAUTION: for the following SetXXX RightDivide is assumed
764
 ## NOT to be lazy evaluated!!!
765
 
766
 SetIsLeftInvertibleMatrix( RI, IsHomalgMatrix( LI ) );
767
 
768
 if IsBool( LI ) then
769
 return fail;
770
 fi;
771
 
772
 if HasIsInvertibleMatrix( RI ) and IsInvertibleMatrix( RI ) then
773
 SetIsInvertibleMatrix( LI, true );
774
 else
775
 SetIsRightInvertibleMatrix( LI, true );
776
 fi;
777
 
778
 SetRightInverse( LI, RI );
779
 
780
 SetNrColumns( LI, NrRows( RI ) );
781
 
782
 if NrRows( RI ) = NrColumns( RI ) then
783
 ## a left inverse of a ring element is unique
784
 ## and coincides with the right inverse
785
 SetRightInverse( RI, LI );
786
 SetLeftInverse( LI, RI );
787
 fi;
788
 
789
 return LI;
790
 
791
end );
792

793
794
5.5-3 RightInverse
795
796
RightInverse( LI )  method
797
Returns: a homalg matrix or fail
798
799
The right inverse of the matrix LI. The lazy version of this operation is
800
RightInverseLazy (5.5-5). (--> LeftDivide (5.5-46))
801
802
 Code 
803
InstallMethod( RightInverse,
804
 "for homalg matrices",
805
 [ IsHomalgMatrix ],
806
 
807
 function( LI )
808
 local Id, RI;
809
 
810
 Id := HomalgIdentityMatrix( NrRows( LI ), HomalgRing( LI ) );
811
 
812
 RI := LeftDivide( LI, Id ); ## ( cf. [BR08, Subsection 3.1.3] )
813
 
814
 ## CAUTION: for the following SetXXX LeftDivide is assumed
815
 ## NOT to be lazy evaluated!!!
816
 
817
 SetIsRightInvertibleMatrix( LI, IsHomalgMatrix( RI ) );
818
 
819
 if IsBool( RI ) then
820
 return fail;
821
 fi;
822
 
823
 if HasIsInvertibleMatrix( LI ) and IsInvertibleMatrix( LI ) then
824
 SetIsInvertibleMatrix( RI, true );
825
 else
826
 SetIsLeftInvertibleMatrix( RI, true );
827
 fi;
828
 
829
 SetLeftInverse( RI, LI );
830
 
831
 SetNrRows( RI, NrColumns( LI ) );
832
 
833
 if NrRows( LI ) = NrColumns( LI ) then
834
 ## a right inverse of a ring element is unique
835
 ## and coincides with the left inverse
836
 SetLeftInverse( LI, RI );
837
 SetRightInverse( RI, LI );
838
 fi;
839
 
840
 return RI;
841
 
842
end );
843

844
845
5.5-4 LeftInverseLazy
846
847
LeftInverseLazy( M )  operation
848
Returns: a homalg matrix
849
850
A lazy evaluated left inverse C of the matrix M. If no left inverse exists
851
then Eval( C ) will issue an error.
852
853
(for the installed standard method see Eval (C.4-5))
854
855
5.5-5 RightInverseLazy
856
857
RightInverseLazy( M )  operation
858
Returns: a homalg matrix
859
860
A lazy evaluated right inverse C of the matrix M. If no right inverse exists
861
then Eval( C ) will issue an error.
862
863
(for the installed standard method see Eval (C.4-6))
864
865
5.5-6 Involution
866
867
Involution( M )  method
868
Returns: a homalg matrix
869
870
The twisted transpose of the homalg matrix M.
871
872
(for the installed standard method see Eval (C.4-7))
873
874
5.5-7 CertainRows
875
876
CertainRows( M, plist )  method
877
Returns: a homalg matrix
878
879
The matrix of which the i-th row is the k-th row of the homalg matrix M,
880
where k=plist[i].
881
882
(for the installed standard method see Eval (C.4-8))
883
884
5.5-8 CertainColumns
885
886
CertainColumns( M, plist )  method
887
Returns: a homalg matrix
888
889
The matrix of which the j-th column is the l-th column of the homalg matrix
890
M, where l=plist[i].
891
892
(for the installed standard method see Eval (C.4-9))
893
894
5.5-9 UnionOfRows
895
896
UnionOfRows( A, B )  method
897
Returns: a homalg matrix
898
899
Stack the two homalg matrices A and B.
900
901
(for the installed standard method see Eval (C.4-10))
902
903
5.5-10 UnionOfColumns
904
905
UnionOfColumns( A, B )  method
906
Returns: a homalg matrix
907
908
Augment the two homalg matrices A and B.
909
910
(for the installed standard method see Eval (C.4-11))
911
912
5.5-11 DiagMat
913
914
DiagMat( list )  method
915
Returns: a homalg matrix
916
917
Build the block diagonal matrix out of the homalg matrices listed in list.
918
An error is issued if list is empty or if one of the arguments is not a
919
homalg matrix.
920
921
(for the installed standard method see Eval (C.4-12))
922
923
5.5-12 KroneckerMat
924
925
KroneckerMat( A, B )  method
926
Returns: a homalg matrix
927
928
The Kronecker (or tensor) product of the two homalg matrices A and B.
929
930
(for the installed standard method see Eval (C.4-13))
931
932
5.5-13 \*
933
934
\*( a, A )  method
935
Returns: a homalg matrix
936
937
The product of the ring element a with the homalg matrix A (enter: a * A;).
938
939
(for the installed standard method see Eval (C.4-14))
940
941
5.5-14 \+
942
943
\+( A, B )  method
944
Returns: a homalg matrix
945
946
The sum of the two homalg matrices A and B (enter: A + B;).
947
948
(for the installed standard method see Eval (C.4-15))
949
950
5.5-15 \-
951
952
\-( A, B )  method
953
Returns: a homalg matrix
954
955
The difference of the two homalg matrices A and B (enter: A - B;).
956
957
(for the installed standard method see Eval (C.4-16))
958
959
5.5-16 \*
960
961
\*( A, B )  method
962
Returns: a homalg matrix
963
964
The matrix product of the two homalg matrices A and B (enter: A * B;).
965
966
(for the installed standard method see Eval (C.4-17))
967
968
5.5-17 \=
969
970
\=( A, B )  operation
971
Returns: true or false
972
973
Check if the homalg matrices A and B are equal (enter: A = B;), taking
974
possible ring relations into account.
975
976
(for the installed standard method see AreEqualMatrices (B.2-1))
977
978
 Example 
979
gap> ZZ := HomalgRingOfIntegers( );
980
Z
981
gap> A := HomalgMatrix( "[ 1 ]", ZZ );
982
<A 1 x 1 matrix over an internal ring>
983
gap> B := HomalgMatrix( "[ 3 ]", ZZ );
984
<A 1 x 1 matrix over an internal ring>
985
gap> Z2 := ZZ / 2;
986
Z/( 2 )
987
gap> A := Z2 * A;
988
<A 1 x 1 matrix over a residue class ring>
989
gap> B := Z2 * B;
990
<A 1 x 1 matrix over a residue class ring>
991
gap> Display( A );
992
[ [ 1 ] ]
993

994
modulo [ 2 ]
995
gap> Display( B );
996
[ [ 3 ] ]
997

998
modulo [ 2 ]
999
gap> A = B;
1000
true
1001

1002
1003
5.5-18 GetColumnIndependentUnitPositions
1004
1005
GetColumnIndependentUnitPositions( A, poslist )  operation
1006
Returns: a (possibly empty) list of pairs of positive integers
1007
1008
The list of column independet unit position of the matrix A. We say that a
1009
unit A[i,k] is column independet from the unit A[l,j] if i>l and A[l,k]=0.
1010
The rows are scanned from top to bottom and within each row the columns are
1011
scanned from right to left searching for new units, column independent from
1012
the preceding ones. If A[i,k] is a new column independent unit then [i,k] is
1013
added to the output list. If A has no units the empty list is returned.
1014
1015
(for the installed standard method see GetColumnIndependentUnitPositions
1016
(B.2-6))
1017
1018
5.5-19 GetRowIndependentUnitPositions
1019
1020
GetRowIndependentUnitPositions( A, poslist )  operation
1021
Returns: a (possibly empty) list of pairs of positive integers
1022
1023
The list of row independet unit position of the matrix A. We say that a unit
1024
A[k,j] is row independet from the unit A[i,l] if j>l and A[k,l]=0. The
1025
columns are scanned from left to right and within each column the rows are
1026
scanned from bottom to top searching for new units, row independent from the
1027
preceding ones. If A[k,j] is a new row independent unit then [j,k] (yes
1028
[j,k]) is added to the output list. If A has no units the empty list is
1029
returned.
1030
1031
(for the installed standard method see GetRowIndependentUnitPositions
1032
(B.2-7))
1033
1034
5.5-20 GetUnitPosition
1035
1036
GetUnitPosition( A, poslist )  operation
1037
Returns: a (possibly empty) list of pairs of positive integers
1038
1039
The position [i,j] of the first unit A[i,j] in the matrix A, where the rows
1040
are scanned from top to bottom and within each row the columns are scanned
1041
from left to right. If A[i,j] is the first occurrence of a unit then the
1042
position pair [i,j] is returned. Otherwise fail is returned.
1043
1044
(for the installed standard method see GetUnitPosition (B.2-8))
1045
1046
5.5-21 Eliminate
1047
1048
Eliminate( rel, indets )  operation
1049
Returns: a homalg matrix
1050
1051
Eliminate the independents indets from the matrix (or list of ring elements)
1052
rel, i.e. compute a generating set of the ideal defined as the intersection
1053
of the ideal generated by the entries of the list rel with the subring
1054
generated by all indeterminates except those in indets. by the list of
1055
indeterminates indets.
1056
1057
5.5-22 BasisOfRowModule
1058
1059
BasisOfRowModule( M )  operation
1060
Returns: a homalg matrix
1061
1062
Let R be the ring over which M is defined (R:=HomalgRing( M )) and S be the
1063
row span of M, i.e. the R-submodule of the free module R^(1 × NrColumns( M
1064
)) spanned by the rows of M. A solution to the submodule membership problem
1065
is an algorithm which can decide if an element m in R^(1 × NrColumns( M ))
1066
is contained in S or not. And exactly like the Gaussian (resp. Hermite)
1067
normal form when R is a field (resp. principal ideal ring), the row span of
1068
the resulting matrix B coincides with the row span S of M, and computing B
1069
is typically the first step of such an algorithm. (--> Appendix A)
1070
1071
5.5-23 BasisOfColumnModule
1072
1073
BasisOfColumnModule( M )  operation
1074
Returns: a homalg matrix
1075
1076
Let R be the ring over which M is defined (R:=HomalgRing( M )) and S be the
1077
column span of M, i.e. the R-submodule of the free module R^(NrRows( M ) ×
1078
1) spanned by the columns of M. A solution to the submodule membership
1079
problem is an algorithm which can decide if an element m in R^(NrRows( M ) ×
1080
1) is contained in S or not. And exactly like the Gaussian (resp. Hermite)
1081
normal form when R is a field (resp. principal ideal ring), the column span
1082
of the resulting matrix B coincides with the column span S of M, and
1083
computing B is typically the first step of such an algorithm. (--> Appendix
1084
A)
1085
1086
5.5-24 DecideZeroRows
1087
1088
DecideZeroRows( A, B )  operation
1089
Returns: a homalg matrix
1090
1091
Let A and B be matrices having the same number of columns and defined over
1092
the same ring R (:=HomalgRing( A )) and S be the row span of B, i.e. the
1093
R-submodule of the free module R^(1 × NrColumns( B )) spanned by the rows of
1094
B. The result is a matrix C having the same shape as A, for which the i-th
1095
row C^i is equivalent to the i-th row A^i of A modulo S, i.e. C^i-A^i is an
1096
element of the row span S of B. Moreover, the row C^i is zero, if and only
1097
if the row A^i is an element of S. So DecideZeroRows decides which rows of A
1098
are zero modulo the rows of B. (--> Appendix A)
1099
1100
5.5-25 DecideZeroColumns
1101
1102
DecideZeroColumns( A, B )  operation
1103
Returns: a homalg matrix
1104
1105
Let A and B be matrices having the same number of rows and defined over the
1106
same ring R (:=HomalgRing( A )) and S be the column span of B, i.e. the
1107
R-submodule of the free module R^(NrRows( B ) × 1) spanned by the columns of
1108
B. The result is a matrix C having the same shape as A, for which the i-th
1109
column C_i is equivalent to the i-th column A_i of A modulo S, i.e. C_i-A_i
1110
is an element of the column span S of B. Moreover, the column C_i is zero,
1111
if and only if the column A_i is an element of S. So DecideZeroColumns
1112
decides which columns of A are zero modulo the columns of B. (--> Appendix
1113
A)
1114
1115
5.5-26 SyzygiesGeneratorsOfRows
1116
1117
SyzygiesGeneratorsOfRows( M )  operation
1118
Returns: a homalg matrix
1119
1120
Let R be the ring over which M is defined (R:=HomalgRing( M )). The matrix
1121
of row syzygies SyzygiesGeneratorsOfRows( M ) is a matrix whose rows span
1122
the left kernel of M, i.e. the R-submodule of the free module R^(1 × NrRows(
1123
M )) consisting of all rows X satisfying XM=0. (--> Appendix A)
1124
1125
5.5-27 SyzygiesGeneratorsOfColumns
1126
1127
SyzygiesGeneratorsOfColumns( M )  operation
1128
Returns: a homalg matrix
1129
1130
Let R be the ring over which M is defined (R:=HomalgRing( M )). The matrix
1131
of column syzygies SyzygiesGeneratorsOfColumns( M ) is a matrix whose
1132
columns span the right kernel of M, i.e. the R-submodule of the free module
1133
R^(NrColumns( M ) × 1) consisting of all columns X satisfying MX=0. (-->
1134
Appendix A)
1135
1136
5.5-28 SyzygiesGeneratorsOfRows
1137
1138
SyzygiesGeneratorsOfRows( M, M2 )  operation
1139
Returns: a homalg matrix
1140
1141
Let R be the ring over which M is defined (R:=HomalgRing( M )). The matrix
1142
of relative row syzygies SyzygiesGeneratorsOfRows( M, M2 ) is a matrix whose
1143
rows span the left kernel of M modulo M2, i.e. the R-submodule of the free
1144
module R^(1 × NrRows( M )) consisting of all rows X satisfying XM+YM2=0 for
1145
some row Y ∈ R^(1 × NrRows( M2 )). (--> Appendix A)
1146
1147
5.5-29 SyzygiesGeneratorsOfColumns
1148
1149
SyzygiesGeneratorsOfColumns( M, M2 )  operation
1150
Returns: a homalg matrix
1151
1152
Let R be the ring over which M is defined (R:=HomalgRing( M )). The matrix
1153
of relative column syzygies SyzygiesGeneratorsOfColumns( M, M2 ) is a matrix
1154
whose columns span the right kernel of M modulo M2, i.e. the R-submodule of
1155
the free module R^(NrColumns( M ) × 1) consisting of all columns X
1156
satisfying MX+M2Y=0 for some column Y ∈ R^(NrColumns( M2 ) × 1). (-->
1157
Appendix A)
1158
1159
5.5-30 ReducedBasisOfRowModule
1160
1161
ReducedBasisOfRowModule( M )  operation
1162
Returns: a homalg matrix
1163
1164
Like BasisOfRowModule( M ) but where the matrix SyzygiesGeneratorsOfRows(
1165
ReducedBasisOfRowModule( M ) ) contains no units. This can easily be
1166
achieved starting from B:=BasisOfRowModule( M ) (and using
1167
GetColumnIndependentUnitPositions (5.5-18) applied to the matrix of row
1168
syzygies of B, etc). (--> Appendix A)
1169
1170
5.5-31 ReducedBasisOfColumnModule
1171
1172
ReducedBasisOfColumnModule( M )  operation
1173
Returns: a homalg matrix
1174
1175
Like BasisOfColumnModule( M ) but where the matrix
1176
SyzygiesGeneratorsOfColumns( ReducedBasisOfColumnModule( M ) ) contains no
1177
units. This can easily be achieved starting from B:=BasisOfColumnModule( M )
1178
(and using GetRowIndependentUnitPositions (5.5-19) applied to the matrix of
1179
column syzygies of B, etc.). (--> Appendix A)
1180
1181
5.5-32 ReducedSyzygiesGeneratorsOfRows
1182
1183
ReducedSyzygiesGeneratorsOfRows( M )  operation
1184
Returns: a homalg matrix
1185
1186
Like SyzygiesGeneratorsOfRows( M ) but where the matrix
1187
SyzygiesGeneratorsOfRows( ReducedSyzygiesGeneratorsOfRows( M ) ) contains no
1188
units. This can easily be achieved starting from
1189
C:=SyzygiesGeneratorsOfRows( M ) (and using
1190
GetColumnIndependentUnitPositions (5.5-18) applied to the matrix of row
1191
syzygies of C, etc.). (--> Appendix A)
1192
1193
5.5-33 ReducedSyzygiesGeneratorsOfColumns
1194
1195
ReducedSyzygiesGeneratorsOfColumns( M )  operation
1196
Returns: a homalg matrix
1197
1198
Like SyzygiesGeneratorsOfColumns( M ) but where the matrix
1199
SyzygiesGeneratorsOfColumns( ReducedSyzygiesGeneratorsOfColumns( M ) )
1200
contains no units. This can easily be achieved starting from
1201
C:=SyzygiesGeneratorsOfColumns( M ) (and using
1202
GetRowIndependentUnitPositions (5.5-19) applied to the matrix of column
1203
syzygies of C, etc.). (--> Appendix A)
1204
1205
5.5-34 BasisOfRowsCoeff
1206
1207
BasisOfRowsCoeff( M, T )  operation
1208
Returns: a homalg matrix
1209
1210
Returns B:=BasisOfRowModule( M ) and assigns the void matrix T (-->
1211
HomalgVoidMatrix (5.2-5)) such that B = T M. (--> Appendix A)
1212
1213
5.5-35 BasisOfColumnsCoeff
1214
1215
BasisOfColumnsCoeff( M, T )  operation
1216
Returns: a homalg matrix
1217
1218
Returns B:=BasisOfRowModule( M ) and assigns the void matrix T (-->
1219
HomalgVoidMatrix (5.2-5)) such that B = M T. (--> Appendix A)
1220
1221
5.5-36 DecideZeroRowsEffectively
1222
1223
DecideZeroRowsEffectively( A, B, T )  operation
1224
Returns: a homalg matrix
1225
1226
Returns M:=DecideZeroRows( A, B ) and assigns the void matrix T (-->
1227
HomalgVoidMatrix (5.2-5)) such that M = A + TB. (--> Appendix A)
1228
1229
5.5-37 DecideZeroColumnsEffectively
1230
1231
DecideZeroColumnsEffectively( A, B, T )  operation
1232
Returns: a homalg matrix
1233
1234
Returns M:=DecideZeroColumns( A, B ) and assigns the void matrix T (-->
1235
HomalgVoidMatrix (5.2-5)) such that M = A + BT. (--> Appendix A)
1236
1237
5.5-38 BasisOfRows
1238
1239
BasisOfRows( M )  operation
1240
BasisOfRows( M, T )  operation
1241
Returns: a homalg matrix
1242
1243
With one argument it is a synonym of BasisOfRowModule (5.5-22). with two
1244
arguments it is a synonym of BasisOfRowsCoeff (5.5-34).
1245
1246
5.5-39 BasisOfColumns
1247
1248
BasisOfColumns( M )  operation
1249
BasisOfColumns( M, T )  operation
1250
Returns: a homalg matrix
1251
1252
With one argument it is a synonym of BasisOfColumnModule (5.5-23). with two
1253
arguments it is a synonym of BasisOfColumnsCoeff (5.5-35).
1254
1255
5.5-40 DecideZero
1256
1257
DecideZero( mat, rel )  operation
1258
Returns: a homalg matrix
1259
1260
 Code 
1261
InstallMethod( DecideZero,
1262
 "for sets of ring relations",
1263
 [ IsHomalgMatrix, IsHomalgRingRelations ],
1264
 
1265
 function( mat, rel )
1266
 
1267
 return DecideZero( mat, MatrixOfRelations( rel ) );
1268
 
1269
end );
1270

1271
1272
5.5-41 SyzygiesOfRows
1273
1274
SyzygiesOfRows( M )  operation
1275
SyzygiesOfRows( M, M2 )  operation
1276
Returns: a homalg matrix
1277
1278
With one argument it is a synonym of SyzygiesGeneratorsOfRows (5.5-26). with
1279
two arguments it is a synonym of SyzygiesGeneratorsOfRows (5.5-28).
1280
1281
5.5-42 SyzygiesOfColumns
1282
1283
SyzygiesOfColumns( M )  operation
1284
SyzygiesOfColumns( M, M2 )  operation
1285
Returns: a homalg matrix
1286
1287
With one argument it is a synonym of SyzygiesGeneratorsOfColumns (5.5-27).
1288
with two arguments it is a synonym of SyzygiesGeneratorsOfColumns (5.5-29).
1289
1290
5.5-43 ReducedSyzygiesOfRows
1291
1292
ReducedSyzygiesOfRows( M )  operation
1293
ReducedSyzygiesOfRows( M, M2 )  operation
1294
Returns: a homalg matrix
1295
1296
With one argument it is a synonym of ReducedSyzygiesGeneratorsOfRows
1297
(5.5-32). With two arguments it calls ReducedBasisOfRowModule(
1298
SyzygiesGeneratorsOfRows( M, M2 ) ). (--> ReducedBasisOfRowModule (5.5-30)
1299
and SyzygiesGeneratorsOfRows (5.5-28))
1300
1301
5.5-44 ReducedSyzygiesOfColumns
1302
1303
ReducedSyzygiesOfColumns( M )  operation
1304
ReducedSyzygiesOfColumns( M, M2 )  operation
1305
Returns: a homalg matrix
1306
1307
With one argument it is a synonym of ReducedSyzygiesGeneratorsOfColumns
1308
(5.5-33). With two arguments it calls ReducedBasisOfColumnModule(
1309
SyzygiesGeneratorsOfColumns( M, M2 ) ). (--> ReducedBasisOfColumnModule
1310
(5.5-31) and SyzygiesGeneratorsOfColumns (5.5-29))
1311
1312
5.5-45 RightDivide
1313
1314
RightDivide( B, A )  operation
1315
Returns: a homalg matrix or fail
1316
1317
Let B and A be matrices having the same number of columns and defined over
1318
the same ring. The matrix RightDivide( B, A ) is a particular solution of
1319
the inhomogeneous (one sided) linear system of equations XA=B in case it is
1320
solvable. Otherwise fail is returned. The name RightDivide suggests X=BA^-1.
1321
This generalizes LeftInverse (5.5-2) for which B becomes the identity
1322
matrix. (--> SyzygiesGeneratorsOfRows (5.5-26))
1323
1324
5.5-46 LeftDivide
1325
1326
LeftDivide( A, B )  operation
1327
Returns: a homalg matrix or fail
1328
1329
Let A and B be matrices having the same number of rows and defined over the
1330
same ring. The matrix LeftDivide( A, B ) is a particular solution of the
1331
inhomogeneous (one sided) linear system of equations AX=B in case it is
1332
solvable. Otherwise fail is returned. The name LeftDivide suggests X=A^-1B.
1333
This generalizes RightInverse (5.5-3) for which B becomes the identity
1334
matrix. (--> SyzygiesGeneratorsOfColumns (5.5-27))
1335
1336
5.5-47 RightDivide
1337
1338
RightDivide( B, A, L )  operation
1339
Returns: a homalg matrix or fail
1340
1341
Let B, A and L be matrices having the same number of columns and defined
1342
over the same ring. The matrix RightDivide( B, A, L ) is a particular
1343
solution of the inhomogeneous (one sided) linear system of equations XA+YL=B
1344
in case it is solvable (for some Y which is forgotten). Otherwise fail is
1345
returned. The name RightDivide suggests X=BA^-1 modulo L. (Cf. [BR08,
1346
Subsection 3.1.1])
1347
1348
 Code 
1349
InstallMethod( RightDivide,
1350
 "for homalg matrices",
1351
 [ IsHomalgMatrix, IsHomalgMatrix, IsHomalgMatrix ],
1352
 
1353
 function( B, A, L ) ## CAUTION: Do not use lazy evaluation here!!!
1354
 local R, BL, ZA, AL, CA, IAL, ZB, CB, NF, X;
1355
 
1356
 R := HomalgRing( B );
1357
 
1358
 BL := BasisOfRows( L );
1359
 
1360
 ## first reduce A modulo L
1361
 ZA := DecideZeroRows( A, BL );
1362
 
1363
 AL := UnionOfRows( ZA, BL );
1364
 
1365
 ## CA * AL = IAL
1366
 CA := HomalgVoidMatrix( R );
1367
 IAL := BasisOfRows( AL, CA );
1368
 
1369
 ## also reduce B modulo L
1370
 ZB := DecideZeroRows( B, BL );
1371
 
1372
 ## knowing this will avoid computations
1373
 IsOne( IAL );
1374
 
1375
 ## IsSpecialSubidentityMatrix( IAL ); ## does not increase performance
1376
 
1377
 ## NF = ZB + CB * IAL
1378
 CB := HomalgVoidMatrix( R );
1379
 NF := DecideZeroRowsEffectively( ZB, IAL, CB );
1380
 
1381
 ## NF <> 0
1382
 if not IsZero( NF ) then
1383
 return fail;
1384
 fi;
1385
 
1386
 ## CD = -CB * CA => CD * A = B
1387
 X := -CB * CertainColumns( CA, [ 1 .. NrRows( A ) ] );
1388
 
1389
 ## check assertion
1390
 Assert( 5, IsZero( DecideZeroRows( X * A - B, BL ) ) );
1391
 
1392
 return X;
1393
 
1394
 ## technical: -CB * CA := (-CB) * CA and COLEM should take over
1395
 ## since CB := -matrix
1396
 
1397
end );
1398

1399
1400
5.5-48 LeftDivide
1401
1402
LeftDivide( A, B, L )  operation
1403
Returns: a homalg matrix or fail
1404
1405
Let A, B and L be matrices having the same number of columns and defined
1406
over the same ring. The matrix LeftDivide( A, B, L ) is a particular
1407
solution of the inhomogeneous (one sided) linear system of equations AX+LY=B
1408
in case it is solvable (for some Y which is forgotten). Otherwise fail is
1409
returned. The name LeftDivide suggests X=A^-1B modulo L. (Cf. [BR08,
1410
Subsection 3.1.1])
1411
1412
 Code 
1413
InstallMethod( LeftDivide,
1414
 "for homalg matrices",
1415
 [ IsHomalgMatrix, IsHomalgMatrix, IsHomalgMatrix ],
1416
 
1417
 function( A, B, L ) ## CAUTION: Do not use lazy evaluation here!!!
1418
 local R, BL, ZA, AL, CA, IAL, ZB, CB, NF, X;
1419
 
1420
 R := HomalgRing( B );
1421
 
1422
 BL := BasisOfColumns( L );
1423
 
1424
 ## first reduce A modulo L
1425
 ZA := DecideZeroColumns( A, BL );
1426
 
1427
 AL := UnionOfColumns( ZA, BL );
1428
 
1429
 ## AL * CA = IAL
1430
 CA := HomalgVoidMatrix( R );
1431
 IAL := BasisOfColumns( AL, CA );
1432
 
1433
 ## also reduce B modulo L
1434
 ZB := DecideZeroColumns( B, BL );
1435
 
1436
 ## knowing this will avoid computations
1437
 IsOne( IAL );
1438
 
1439
 ## IsSpecialSubidentityMatrix( IAL ); ## does not increase performance
1440
 
1441
 ## NF = ZB + IAL * CB
1442
 CB := HomalgVoidMatrix( R );
1443
 NF := DecideZeroColumnsEffectively( ZB, IAL, CB );
1444
 
1445
 ## NF <> 0
1446
 if not IsZero( NF ) then
1447
 return fail;
1448
 fi;
1449
 
1450
 ## CD = CA * -CB => A * CD = B
1451
 X := CertainRows( CA, [ 1 .. NrColumns( A ) ] ) * -CB;
1452
 
1453
 ## check assertion
1454
 Assert( 5, IsZero( DecideZeroColumns( A * X - B, BL ) ) );
1455
 
1456
 return X;
1457
 
1458
 ## technical: CA * -CB := CA * (-CB) and COLEM should take over since
1459
 ## CB := -matrix
1460
 
1461
end );
1462

1463
1464
5.5-49 GenerateSameRowModule
1465
1466
GenerateSameRowModule( M, N )  operation
1467
Returns: true or false
1468
1469
Check if the row span of M and of N are identical or not (--> RightDivide
1470
(5.5-45)).
1471
1472
5.5-50 GenerateSameColumnModule
1473
1474
GenerateSameColumnModule( M, N )  operation
1475
Returns: true or false
1476
1477
Check if the column span of M and of N are identical or not (--> LeftDivide
1478
(5.5-46)).
1479
1480
1481