CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

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

Views: 418346
1
2
C Logic Subpackages
3
4
5
C.1 LIRNG: Logical Implications for Rings
6
7
8
C.2 LIMAP: Logical Implications for Ring Maps
9
10
11
C.3 LIMAT: Logical Implications for Matrices
12
13
14
C.4 COLEM: Clever Operations for Lazy Evaluated Matrices
15
16
Most of the matrix tool operations listed in Appendix B.1 which return a new
17
matrix are lazy evaluated. The value of a homalg matrix is stored in the
18
attribute Eval. Below is the list of the installed methods for the attribute
19
Eval.
20
21
C.4-1 Eval
22
23
Eval( C )  method
24
Returns: the Eval value of a homalg matrix C
25
26
In case the matrix C was created using HomalgInitialMatrix (5.2-1) then the
27
filter IsInitialMatrix for C is set to true and the homalgTable function
28
(--> InitialMatrix (B.1-1)) will be used to set the attribute Eval and
29
resets the filter IsInitialMatrix.
30
31
 Code 
32
InstallMethod( Eval,
33
 "for homalg matrices (IsInitialMatrix)",
34
 [ IsHomalgMatrix and IsInitialMatrix and
35
 HasNrRows and HasNrColumns ],
36
 
37
 function( C )
38
 local R, RP, z, zz;
39
 
40
 R := HomalgRing( C );
41
 
42
 RP := homalgTable( R );
43
 
44
 if IsBound( RP!.InitialMatrix ) then
45
 ResetFilterObj( C, IsInitialMatrix );
46
 return RP!.InitialMatrix( C );
47
 fi;
48
 
49
 if not IsHomalgInternalMatrixRep( C ) then
50
 Error( "could not find a procedure called InitialMatrix in the ",
51
 "homalgTable to evaluate a non-internal initial matrix\n" );
52
 fi;
53
 
54
 #=====# can only work for homalg internal matrices #=====#
55
 
56
 z := Zero( HomalgRing( C ) );
57
 
58
 ResetFilterObj( C, IsInitialMatrix );
59
 
60
 zz := ListWithIdenticalEntries( NrColumns( C ), z );
61
 
62
 return homalgInternalMatrixHull(
63
 List( [ 1 .. NrRows( C ) ], i -> ShallowCopy( zz ) ) );
64
 
65
end );
66

67
68
C.4-2 Eval
69
70
Eval( C )  method
71
Returns: the Eval value of a homalg matrix C
72
73
In case the matrix C was created using HomalgInitialIdentityMatrix (5.2-2)
74
then the filter IsInitialIdentityMatrix for C is set to true and the
75
homalgTable function (--> InitialIdentityMatrix (B.1-2)) will be used to set
76
the attribute Eval and resets the filter IsInitialIdentityMatrix.
77
78
 Code 
79
InstallMethod( Eval,
80
 "for homalg matrices (IsInitialIdentityMatrix)",
81
 [ IsHomalgMatrix and IsInitialIdentityMatrix and
82
 HasNrRows and HasNrColumns ],
83
 
84
 function( C )
85
 local R, RP, o, z, zz, id;
86
 
87
 R := HomalgRing( C );
88
 
89
 RP := homalgTable( R );
90
 
91
 if IsBound( RP!.InitialIdentityMatrix ) then
92
 ResetFilterObj( C, IsInitialIdentityMatrix );
93
 return RP!.InitialIdentityMatrix( C );
94
 fi;
95
 
96
 if not IsHomalgInternalMatrixRep( C ) then
97
 Error( "could not find a procedure called InitialIdentityMatrix in the ",
98
 "homalgTable to evaluate a non-internal initial identity matrix\n" );
99
 fi;
100
 
101
 #=====# can only work for homalg internal matrices #=====#
102
 
103
 z := Zero( HomalgRing( C ) );
104
 o := One( HomalgRing( C ) );
105
 
106
 ResetFilterObj( C, IsInitialIdentityMatrix );
107
 
108
 zz := ListWithIdenticalEntries( NrColumns( C ), z );
109
 
110
 id := List( [ 1 .. NrRows( C ) ],
111
 function(i)
112
 local z;
113
 z := ShallowCopy( zz ); z[i] := o; return z;
114
 end );
115
 
116
 return homalgInternalMatrixHull( id );
117
 
118
end );
119

120
121
C.4-3 Eval
122
123
Eval( C )  method
124
Returns: the Eval value of a homalg matrix C
125
126
In case the matrix C was created using HomalgZeroMatrix (5.2-3) then the
127
filter IsZeroMatrix for C is set to true and the homalgTable function (-->
128
ZeroMatrix (B.1-3)) will be used to set the attribute Eval.
129
130
 Code 
131
InstallMethod( Eval,
132
 "for homalg matrices (IsZero)",
133
 [ IsHomalgMatrix and IsZero and HasNrRows and HasNrColumns ], 20,
134
 
135
 function( C )
136
 local R, RP, z;
137
 
138
 R := HomalgRing( C );
139
 
140
 RP := homalgTable( R );
141
 
142
 if ( NrRows( C ) = 0 or NrColumns( C ) = 0 ) and
143
 not ( IsBound( R!.SafeToEvaluateEmptyMatrices ) and
144
 R!.SafeToEvaluateEmptyMatrices = true ) then
145
 Info( InfoWarning, 1, "\033[01m\033[5;31;47m",
146
 "an empty matrix is about to get evaluated!",
147
 "\033[0m" );
148
 fi;
149
 
150
 if IsBound( RP!.ZeroMatrix ) then
151
 return RP!.ZeroMatrix( C );
152
 fi;
153
 
154
 if not IsHomalgInternalMatrixRep( C ) then
155
 Error( "could not find a procedure called ZeroMatrix ",
156
 "homalgTable to evaluate a non-internal zero matrix\n" );
157
 fi;
158
 
159
 #=====# can only work for homalg internal matrices #=====#
160
 
161
 z := Zero( HomalgRing( C ) );
162
 
163
 ## copying the rows saves memory;
164
 ## we assume that the entries are never modified!!!
165
 return homalgInternalMatrixHull(
166
 ListWithIdenticalEntries( NrRows( C ),
167
 ListWithIdenticalEntries( NrColumns( C ), z ) ) );
168
 
169
end );
170

171
172
C.4-4 Eval
173
174
Eval( C )  method
175
Returns: the Eval value of a homalg matrix C
176
177
In case the matrix C was created using HomalgIdentityMatrix (5.2-4) then the
178
filter IsOne for C is set to true and the homalgTable function (-->
179
IdentityMatrix (B.1-4)) will be used to set the attribute Eval.
180
181
 Code 
182
InstallMethod( Eval,
183
 "for homalg matrices (IsOne)",
184
 [ IsHomalgMatrix and IsOne and HasNrRows and HasNrColumns ], 10,
185
 
186
 function( C )
187
 local R, id, RP, o, z, zz;
188
 
189
 R := HomalgRing( C );
190
 
191
 if IsBound( R!.IdentityMatrices ) then
192
 id := ElmWPObj( R!.IdentityMatrices!.weak_pointers, NrColumns( C ) );
193
 if id <> fail then
194
 R!.IdentityMatrices!.cache_hits := R!.IdentityMatrices!.cache_hits + 1;
195
 return id;
196
 fi;
197
 ## we do not count cache_misses as it is equivalent to counter
198
 fi;
199
 
200
 RP := homalgTable( R );
201
 
202
 if IsBound( RP!.IdentityMatrix ) then
203
 id := RP!.IdentityMatrix( C );
204
 SetElmWPObj( R!.IdentityMatrices!.weak_pointers, NrColumns( C ), id );
205
 R!.IdentityMatrices!.counter := R!.IdentityMatrices!.counter + 1;
206
 return id;
207
 fi;
208
 
209
 if not IsHomalgInternalMatrixRep( C ) then
210
 Error( "could not find a procedure called IdentityMatrix ",
211
 "homalgTable to evaluate a non-internal identity matrix\n" );
212
 fi;
213
 
214
 #=====# can only work for homalg internal matrices #=====#
215
 
216
 z := Zero( HomalgRing( C ) );
217
 o := One( HomalgRing( C ) );
218
 
219
 zz := ListWithIdenticalEntries( NrColumns( C ), z );
220
 
221
 id := List( [ 1 .. NrRows( C ) ],
222
 function(i)
223
 local z;
224
 z := ShallowCopy( zz ); z[i] := o; return z;
225
 end );
226
 
227
 id := homalgInternalMatrixHull( id );
228
 
229
 SetElmWPObj( R!.IdentityMatrices!.weak_pointers, NrColumns( C ), id );
230
 
231
 return id;
232
 
233
end );
234

235
236
C.4-5 Eval
237
238
Eval( LI )  method
239
Returns: see below
240
241
In case the matrix LI was created using LeftInverseLazy (5.5-4) then the
242
filter HasEvalLeftInverse for LI is set to true and the method listed below
243
will be used to set the attribute Eval. (--> LeftInverse (5.5-2))
244
245
 Code 
246
InstallMethod( Eval,
247
 "for homalg matrices",
248
 [ IsHomalgMatrix and HasEvalLeftInverse ],
249
 
250
 function( LI )
251
 local left_inv;
252
 
253
 left_inv := LeftInverse( EvalLeftInverse( LI ) );
254
 
255
 if IsBool( left_inv ) then
256
 return false;
257
 fi;
258
 
259
 return Eval( left_inv );
260
 
261
end );
262

263
264
C.4-6 Eval
265
266
Eval( RI )  method
267
Returns: see below
268
269
In case the matrix RI was created using RightInverseLazy (5.5-5) then the
270
filter HasEvalRightInverse for RI is set to true and the method listed below
271
will be used to set the attribute Eval. (--> RightInverse (5.5-3))
272
273
 Code 
274
InstallMethod( Eval,
275
 "for homalg matrices",
276
 [ IsHomalgMatrix and HasEvalRightInverse ],
277
 
278
 function( RI )
279
 local right_inv;
280
 
281
 right_inv := RightInverse( EvalRightInverse( RI ) );
282
 
283
 if IsBool( right_inv ) then
284
 return false;
285
 fi;
286
 
287
 return Eval( right_inv );
288
 
289
end );
290

291
292
C.4-7 Eval
293
294
Eval( C )  method
295
Returns: the Eval value of a homalg matrix C
296
297
In case the matrix was created using Involution (5.5-6) then the filter
298
HasEvalInvolution for C is set to true and the homalgTable function
299
Involution (B.1-5) will be used to set the attribute Eval.
300
301
 Code 
302
InstallMethod( Eval,
303
 "for homalg matrices (HasEvalInvolution)",
304
 [ IsHomalgMatrix and HasEvalInvolution ],
305
 
306
 function( C )
307
 local R, RP, M;
308
 
309
 R := HomalgRing( C );
310
 
311
 RP := homalgTable( R );
312
 
313
 M := EvalInvolution( C );
314
 
315
 if IsBound(RP!.Involution) then
316
 return RP!.Involution( M );
317
 fi;
318
 
319
 if not IsHomalgInternalMatrixRep( C ) then
320
 Error( "could not find a procedure called Involution ",
321
 "in the homalgTable of the non-internal ring\n" );
322
 fi;
323
 
324
 #=====# can only work for homalg internal matrices #=====#
325
 
326
 return homalgInternalMatrixHull( TransposedMat( Eval( M )!.matrix ) );
327
 
328
end );
329

330
331
C.4-8 Eval
332
333
Eval( C )  method
334
Returns: the Eval value of a homalg matrix C
335
336
In case the matrix was created using CertainRows (5.5-7) then the filter
337
HasEvalCertainRows for C is set to true and the homalgTable function
338
CertainRows (B.1-6) will be used to set the attribute Eval.
339
340
 Code 
341
InstallMethod( Eval,
342
 "for homalg matrices (HasEvalCertainRows)",
343
 [ IsHomalgMatrix and HasEvalCertainRows ],
344
 
345
 function( C )
346
 local R, RP, e, M, plist;
347
 
348
 R := HomalgRing( C );
349
 
350
 RP := homalgTable( R );
351
 
352
 e := EvalCertainRows( C );
353
 
354
 M := e[1];
355
 plist := e[2];
356
 
357
 if IsBound(RP!.CertainRows) then
358
 return RP!.CertainRows( M, plist );
359
 fi;
360
 
361
 if not IsHomalgInternalMatrixRep( C ) then
362
 Error( "could not find a procedure called CertainRows ",
363
 "in the homalgTable of the non-internal ring\n" );
364
 fi;
365
 
366
 #=====# can only work for homalg internal matrices #=====#
367
 
368
 return homalgInternalMatrixHull( Eval( M )!.matrix{ plist } );
369
 
370
end );
371

372
373
C.4-9 Eval
374
375
Eval( C )  method
376
Returns: the Eval value of a homalg matrix C
377
378
In case the matrix was created using CertainColumns (5.5-8) then the filter
379
HasEvalCertainColumns for C is set to true and the homalgTable function
380
CertainColumns (B.1-7) will be used to set the attribute Eval.
381
382
 Code 
383
InstallMethod( Eval,
384
 "for homalg matrices (HasEvalCertainColumns)",
385
 [ IsHomalgMatrix and HasEvalCertainColumns ],
386
 
387
 function( C )
388
 local R, RP, e, M, plist;
389
 
390
 R := HomalgRing( C );
391
 
392
 RP := homalgTable( R );
393
 
394
 e := EvalCertainColumns( C );
395
 
396
 M := e[1];
397
 plist := e[2];
398
 
399
 if IsBound(RP!.CertainColumns) then
400
 return RP!.CertainColumns( M, plist );
401
 fi;
402
 
403
 if not IsHomalgInternalMatrixRep( C ) then
404
 Error( "could not find a procedure called CertainColumns ",
405
 "in the homalgTable of the non-internal ring\n" );
406
 fi;
407
 
408
 #=====# can only work for homalg internal matrices #=====#
409
 
410
 return homalgInternalMatrixHull(
411
 Eval( M )!.matrix{[ 1 .. NrRows( M ) ]}{plist} );
412
 
413
end );
414

415
416
C.4-10 Eval
417
418
Eval( C )  method
419
Returns: the Eval value of a homalg matrix C
420
421
In case the matrix was created using UnionOfRows (5.5-9) then the filter
422
HasEvalUnionOfRows for C is set to true and the homalgTable function
423
UnionOfRows (B.1-8) will be used to set the attribute Eval.
424
425
 Code 
426
InstallMethod( Eval,
427
 "for homalg matrices (HasEvalUnionOfRows)",
428
 [ IsHomalgMatrix and HasEvalUnionOfRows ],
429
 
430
 function( C )
431
 local R, RP, e, A, B, U;
432
 
433
 R := HomalgRing( C );
434
 
435
 RP := homalgTable( R );
436
 
437
 e := EvalUnionOfRows( C );
438
 
439
 A := e[1];
440
 B := e[2];
441
 
442
 if IsBound(RP!.UnionOfRows) then
443
 return RP!.UnionOfRows( A, B );
444
 fi;
445
 
446
 if not IsHomalgInternalMatrixRep( C ) then
447
 Error( "could not find a procedure called UnionOfRows ",
448
 "in the homalgTable of the non-internal ring\n" );
449
 fi;
450
 
451
 #=====# can only work for homalg internal matrices #=====#
452
 
453
 U := ShallowCopy( Eval( A )!.matrix );
454
 
455
 U{ [ NrRows( A ) + 1 .. NrRows( A ) + NrRows( B ) ] } := Eval( B )!.matrix;
456
 
457
 return homalgInternalMatrixHull( U );
458
 
459
end );
460

461
462
C.4-11 Eval
463
464
Eval( C )  method
465
Returns: the Eval value of a homalg matrix C
466
467
In case the matrix was created using UnionOfColumns (5.5-10) then the filter
468
HasEvalUnionOfColumns for C is set to true and the homalgTable function
469
UnionOfColumns (B.1-9) will be used to set the attribute Eval.
470
471
 Code 
472
InstallMethod( Eval,
473
 "for homalg matrices (HasEvalUnionOfColumns)",
474
 [ IsHomalgMatrix and HasEvalUnionOfColumns ],
475
 
476
 function( C )
477
 local R, RP, e, A, B, U;
478
 
479
 R := HomalgRing( C );
480
 
481
 RP := homalgTable( R );
482
 
483
 e := EvalUnionOfColumns( C );
484
 
485
 A := e[1];
486
 B := e[2];
487
 
488
 if IsBound(RP!.UnionOfColumns) then
489
 return RP!.UnionOfColumns( A, B );
490
 fi;
491
 
492
 if not IsHomalgInternalMatrixRep( C ) then
493
 Error( "could not find a procedure called UnionOfColumns ",
494
 "in the homalgTable of the non-internal ring\n" );
495
 fi;
496
 
497
 #=====# can only work for homalg internal matrices #=====#
498
 
499
 U := List( Eval( A )!.matrix, ShallowCopy );
500
 
501
 U{ [ 1 .. NrRows( A ) ] }
502
 { [ NrColumns( A ) + 1 .. NrColumns( A ) + NrColumns( B ) ] }
503
 := Eval( B )!.matrix;
504
 
505
 return homalgInternalMatrixHull( U );
506
 
507
end );
508

509
510
C.4-12 Eval
511
512
Eval( C )  method
513
Returns: the Eval value of a homalg matrix C
514
515
In case the matrix was created using DiagMat (5.5-11) then the filter
516
HasEvalDiagMat for C is set to true and the homalgTable function DiagMat
517
(B.1-10) will be used to set the attribute Eval.
518
519
 Code 
520
InstallMethod( Eval,
521
 "for homalg matrices (HasEvalDiagMat)",
522
 [ IsHomalgMatrix and HasEvalDiagMat ],
523
 
524
 function( C )
525
 local R, RP, e, z, m, n, diag, mat;
526
 
527
 R := HomalgRing( C );
528
 
529
 RP := homalgTable( R );
530
 
531
 e := EvalDiagMat( C );
532
 
533
 if IsBound(RP!.DiagMat) then
534
 return RP!.DiagMat( e );
535
 fi;
536
 
537
 if not IsHomalgInternalMatrixRep( C ) then
538
 Error( "could not find a procedure called DiagMat ",
539
 "in the homalgTable of the non-internal ring\n" );
540
 fi;
541
 
542
 #=====# can only work for homalg internal matrices #=====#
543
 
544
 z := Zero( R );
545
 
546
 m := Sum( List( e, NrRows ) );
547
 n := Sum( List( e, NrColumns ) );
548
 
549
 diag := List( [ 1 .. m ], a -> List( [ 1 .. n ], b -> z ) );
550
 
551
 m := 0;
552
 n := 0;
553
 
554
 for mat in e do
555
 diag{ [ m + 1 .. m + NrRows( mat ) ] }{ [ n + 1 .. n + NrColumns( mat ) ] }
556
 := Eval( mat )!.matrix;
557
 
558
 m := m + NrRows( mat );
559
 n := n + NrColumns( mat );
560
 od;
561
 
562
 return homalgInternalMatrixHull( diag );
563
 
564
end );
565

566
567
C.4-13 Eval
568
569
Eval( C )  method
570
Returns: the Eval value of a homalg matrix C
571
572
In case the matrix was created using KroneckerMat (5.5-12) then the filter
573
HasEvalKroneckerMat for C is set to true and the homalgTable function
574
KroneckerMat (B.1-11) will be used to set the attribute Eval.
575
576
 Code 
577
InstallMethod( Eval,
578
 "for homalg matrices (HasEvalKroneckerMat)",
579
 [ IsHomalgMatrix and HasEvalKroneckerMat ],
580
 
581
 function( C )
582
 local R, RP, A, B;
583
 
584
 R := HomalgRing( C );
585
 
586
 if ( HasIsCommutative( R ) and not IsCommutative( R ) ) and
587
 ( HasIsSuperCommutative( R ) and not IsSuperCommutative( R ) ) then
588
 Info( InfoWarning, 1, "\033[01m\033[5;31;47m",
589
 "the Kronecker product is only defined for (super) commutative rings!",
590
 "\033[0m" );
591
 fi;
592
 
593
 RP := homalgTable( R );
594
 
595
 A := EvalKroneckerMat( C )[1];
596
 B := EvalKroneckerMat( C )[2];
597
 
598
 if IsBound(RP!.KroneckerMat) then
599
 return RP!.KroneckerMat( A, B );
600
 fi;
601
 
602
 if not IsHomalgInternalMatrixRep( C ) then
603
 Error( "could not find a procedure called KroneckerMat ",
604
 "in the homalgTable of the non-internal ring\n" );
605
 fi;
606
 
607
 #=====# can only work for homalg internal matrices #=====#
608
 
609
 return homalgInternalMatrixHull(
610
 KroneckerProduct( Eval( A )!.matrix, Eval( B )!.matrix ) );
611
 ## this was easy, thanks GAP :)
612
 
613
end );
614

615
616
C.4-14 Eval
617
618
Eval( C )  method
619
Returns: the Eval value of a homalg matrix C
620
621
In case the matrix was created using \* (5.5-13) then the filter
622
HasEvalMulMat for C is set to true and the homalgTable function MulMat
623
(B.1-12) will be used to set the attribute Eval.
624
625
 Code 
626
InstallMethod( Eval,
627
 "for homalg matrices (HasEvalMulMat)",
628
 [ IsHomalgMatrix and HasEvalMulMat ],
629
 
630
 function( C )
631
 local R, RP, e, a, A;
632
 
633
 R := HomalgRing( C );
634
 
635
 RP := homalgTable( R );
636
 
637
 e := EvalMulMat( C );
638
 
639
 a := e[1];
640
 A := e[2];
641
 
642
 if IsBound(RP!.MulMat) then
643
 return RP!.MulMat( a, A );
644
 fi;
645
 
646
 if not IsHomalgInternalMatrixRep( C ) then
647
 Error( "could not find a procedure called MulMat ",
648
 "in the homalgTable of the non-internal ring\n" );
649
 fi;
650
 
651
 #=====# can only work for homalg internal matrices #=====#
652
 
653
 return a * Eval( A );
654
 
655
end );
656

657
InstallMethod( Eval,
658
 "for homalg matrices (HasEvalMulMatRight)",
659
 [ IsHomalgMatrix and HasEvalMulMatRight ],
660
 
661
 function( C )
662
 local R, RP, e, A, a;
663
 
664
 R := HomalgRing( C );
665
 
666
 RP := homalgTable( R );
667
 
668
 e := EvalMulMatRight( C );
669
 
670
 A := e[1];
671
 a := e[2];
672
 
673
 if IsBound(RP!.MulMatRight) then
674
 return RP!.MulMatRight( A, a );
675
 fi;
676
 
677
 if not IsHomalgInternalMatrixRep( C ) then
678
 Error( "could not find a procedure called MulMatRight ",
679
 "in the homalgTable of the non-internal ring\n" );
680
 fi;
681
 
682
 #=====# can only work for homalg internal matrices #=====#
683
 
684
 return Eval( A ) * a;
685
 
686
end );
687

688
689
C.4-15 Eval
690
691
Eval( C )  method
692
Returns: the Eval value of a homalg matrix C
693
694
In case the matrix was created using \+ (5.5-14) then the filter
695
HasEvalAddMat for C is set to true and the homalgTable function AddMat
696
(B.1-13) will be used to set the attribute Eval.
697
698
 Code 
699
InstallMethod( Eval,
700
 "for homalg matrices (HasEvalAddMat)",
701
 [ IsHomalgMatrix and HasEvalAddMat ],
702
 
703
 function( C )
704
 local R, RP, e, A, B;
705
 
706
 R := HomalgRing( C );
707
 
708
 RP := homalgTable( R );
709
 
710
 e := EvalAddMat( C );
711
 
712
 A := e[1];
713
 B := e[2];
714
 
715
 if IsBound(RP!.AddMat) then
716
 return RP!.AddMat( A, B );
717
 fi;
718
 
719
 if not IsHomalgInternalMatrixRep( C ) then
720
 Error( "could not find a procedure called AddMat ",
721
 "in the homalgTable of the non-internal ring\n" );
722
 fi;
723
 
724
 #=====# can only work for homalg internal matrices #=====#
725
 
726
 return Eval( A ) + Eval( B );
727
 
728
end );
729

730
731
C.4-16 Eval
732
733
Eval( C )  method
734
Returns: the Eval value of a homalg matrix C
735
736
In case the matrix was created using \- (5.5-15) then the filter
737
HasEvalSubMat for C is set to true and the homalgTable function SubMat
738
(B.1-14) will be used to set the attribute Eval.
739
740
 Code 
741
InstallMethod( Eval,
742
 "for homalg matrices (HasEvalSubMat)",
743
 [ IsHomalgMatrix and HasEvalSubMat ],
744
 
745
 function( C )
746
 local R, RP, e, A, B;
747
 
748
 R := HomalgRing( C );
749
 
750
 RP := homalgTable( R );
751
 
752
 e := EvalSubMat( C );
753
 
754
 A := e[1];
755
 B := e[2];
756
 
757
 if IsBound(RP!.SubMat) then
758
 return RP!.SubMat( A, B );
759
 fi;
760
 
761
 if not IsHomalgInternalMatrixRep( C ) then
762
 Error( "could not find a procedure called SubMat ",
763
 "in the homalgTable of the non-internal ring\n" );
764
 fi;
765
 
766
 #=====# can only work for homalg internal matrices #=====#
767
 
768
 return Eval( A ) - Eval( B );
769
 
770
end );
771

772
773
C.4-17 Eval
774
775
Eval( C )  method
776
Returns: the Eval value of a homalg matrix C
777
778
In case the matrix was created using \* (5.5-16) then the filter
779
HasEvalCompose for C is set to true and the homalgTable function Compose
780
(B.1-15) will be used to set the attribute Eval.
781
782
 Code 
783
InstallMethod( Eval,
784
 "for homalg matrices (HasEvalCompose)",
785
 [ IsHomalgMatrix and HasEvalCompose ],
786
 
787
 function( C )
788
 local R, RP, e, A, B;
789
 
790
 R := HomalgRing( C );
791
 
792
 RP := homalgTable( R );
793
 
794
 e := EvalCompose( C );
795
 
796
 A := e[1];
797
 B := e[2];
798
 
799
 if IsBound(RP!.Compose) then
800
 return RP!.Compose( A, B );
801
 fi;
802
 
803
 if not IsHomalgInternalMatrixRep( C ) then
804
 Error( "could not find a procedure called Compose ",
805
 "in the homalgTable of the non-internal ring\n" );
806
 fi;
807
 
808
 #=====# can only work for homalg internal matrices #=====#
809
 
810
 return Eval( A ) * Eval( B );
811
 
812
end );
813

814
815
816