Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
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
Project: cocalc-sagemath-dev-slelievre
Views: 4183461[1XC [33X[0;0YLogic Subpackages[133X[101X234[1XC.1 [33X[0;0Y[5XLIRNG[105X[101X[1X: Logical Implications for Rings[133X[101X567[1XC.2 [33X[0;0Y[5XLIMAP[105X[101X[1X: Logical Implications for Ring Maps[133X[101X8910[1XC.3 [33X[0;0Y[5XLIMAT[105X[101X[1X: Logical Implications for Matrices[133X[101X111213[1XC.4 [33X[0;0Y[5XCOLEM[105X[101X[1X: Clever Operations for Lazy Evaluated Matrices[133X[101X1415[33X[0;0YMost of the matrix tool operations listed in Appendix [14XB.1[114X which return a new16matrix are lazy evaluated. The value of a [5Xhomalg[105X matrix is stored in the17attribute [10XEval[110X. Below is the list of the installed methods for the attribute18[10XEval[110X.[133X1920[1XC.4-1 Eval[101X2122[29X[2XEval[102X( [3XC[103X ) [32X method23[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X2425[33X[0;0YIn case the matrix [3XC[103X was created using [2XHomalgInitialMatrix[102X ([14X5.2-1[114X) then the26filter [10XIsInitialMatrix[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function27(--> [2XInitialMatrix[102X ([14XB.1-1[114X)) will be used to set the attribute [10XEval[110X and28resets the filter [10XIsInitialMatrix[110X.[133X2930[4X[32X Code [32X[104X31[4XInstallMethod( Eval,[104X32[4X "for homalg matrices (IsInitialMatrix)",[104X33[4X [ IsHomalgMatrix and IsInitialMatrix and[104X34[4X HasNrRows and HasNrColumns ],[104X35[4X [104X36[4X function( C )[104X37[4X local R, RP, z, zz;[104X38[4X [104X39[4X R := HomalgRing( C );[104X40[4X [104X41[4X RP := homalgTable( R );[104X42[4X [104X43[4X if IsBound( RP!.InitialMatrix ) then[104X44[4X ResetFilterObj( C, IsInitialMatrix );[104X45[4X return RP!.InitialMatrix( C );[104X46[4X fi;[104X47[4X [104X48[4X if not IsHomalgInternalMatrixRep( C ) then[104X49[4X Error( "could not find a procedure called InitialMatrix in the ",[104X50[4X "homalgTable to evaluate a non-internal initial matrix\n" );[104X51[4X fi;[104X52[4X [104X53[4X #=====# can only work for homalg internal matrices #=====#[104X54[4X [104X55[4X z := Zero( HomalgRing( C ) );[104X56[4X [104X57[4X ResetFilterObj( C, IsInitialMatrix );[104X58[4X [104X59[4X zz := ListWithIdenticalEntries( NrColumns( C ), z );[104X60[4X [104X61[4X return homalgInternalMatrixHull([104X62[4X List( [ 1 .. NrRows( C ) ], i -> ShallowCopy( zz ) ) );[104X63[4X [104X64[4Xend );[104X65[4X[32X[104X6667[1XC.4-2 Eval[101X6869[29X[2XEval[102X( [3XC[103X ) [32X method70[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X7172[33X[0;0YIn case the matrix [3XC[103X was created using [2XHomalgInitialIdentityMatrix[102X ([14X5.2-2[114X)73then the filter [10XIsInitialIdentityMatrix[110X for [3XC[103X is set to true and the74[10XhomalgTable[110X function (--> [2XInitialIdentityMatrix[102X ([14XB.1-2[114X)) will be used to set75the attribute [10XEval[110X and resets the filter [10XIsInitialIdentityMatrix[110X.[133X7677[4X[32X Code [32X[104X78[4XInstallMethod( Eval,[104X79[4X "for homalg matrices (IsInitialIdentityMatrix)",[104X80[4X [ IsHomalgMatrix and IsInitialIdentityMatrix and[104X81[4X HasNrRows and HasNrColumns ],[104X82[4X [104X83[4X function( C )[104X84[4X local R, RP, o, z, zz, id;[104X85[4X [104X86[4X R := HomalgRing( C );[104X87[4X [104X88[4X RP := homalgTable( R );[104X89[4X [104X90[4X if IsBound( RP!.InitialIdentityMatrix ) then[104X91[4X ResetFilterObj( C, IsInitialIdentityMatrix );[104X92[4X return RP!.InitialIdentityMatrix( C );[104X93[4X fi;[104X94[4X [104X95[4X if not IsHomalgInternalMatrixRep( C ) then[104X96[4X Error( "could not find a procedure called InitialIdentityMatrix in the ",[104X97[4X "homalgTable to evaluate a non-internal initial identity matrix\n" );[104X98[4X fi;[104X99[4X [104X100[4X #=====# can only work for homalg internal matrices #=====#[104X101[4X [104X102[4X z := Zero( HomalgRing( C ) );[104X103[4X o := One( HomalgRing( C ) );[104X104[4X [104X105[4X ResetFilterObj( C, IsInitialIdentityMatrix );[104X106[4X [104X107[4X zz := ListWithIdenticalEntries( NrColumns( C ), z );[104X108[4X [104X109[4X id := List( [ 1 .. NrRows( C ) ],[104X110[4X function(i)[104X111[4X local z;[104X112[4X z := ShallowCopy( zz ); z[i] := o; return z;[104X113[4X end );[104X114[4X [104X115[4X return homalgInternalMatrixHull( id );[104X116[4X [104X117[4Xend );[104X118[4X[32X[104X119120[1XC.4-3 Eval[101X121122[29X[2XEval[102X( [3XC[103X ) [32X method123[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X124125[33X[0;0YIn case the matrix [3XC[103X was created using [2XHomalgZeroMatrix[102X ([14X5.2-3[114X) then the126filter [10XIsZeroMatrix[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function (-->127[2XZeroMatrix[102X ([14XB.1-3[114X)) will be used to set the attribute [10XEval[110X.[133X128129[4X[32X Code [32X[104X130[4XInstallMethod( Eval,[104X131[4X "for homalg matrices (IsZero)",[104X132[4X [ IsHomalgMatrix and IsZero and HasNrRows and HasNrColumns ], 20,[104X133[4X [104X134[4X function( C )[104X135[4X local R, RP, z;[104X136[4X [104X137[4X R := HomalgRing( C );[104X138[4X [104X139[4X RP := homalgTable( R );[104X140[4X [104X141[4X if ( NrRows( C ) = 0 or NrColumns( C ) = 0 ) and[104X142[4X not ( IsBound( R!.SafeToEvaluateEmptyMatrices ) and[104X143[4X R!.SafeToEvaluateEmptyMatrices = true ) then[104X144[4X Info( InfoWarning, 1, "\033[01m\033[5;31;47m",[104X145[4X "an empty matrix is about to get evaluated!",[104X146[4X "\033[0m" );[104X147[4X fi;[104X148[4X [104X149[4X if IsBound( RP!.ZeroMatrix ) then[104X150[4X return RP!.ZeroMatrix( C );[104X151[4X fi;[104X152[4X [104X153[4X if not IsHomalgInternalMatrixRep( C ) then[104X154[4X Error( "could not find a procedure called ZeroMatrix ",[104X155[4X "homalgTable to evaluate a non-internal zero matrix\n" );[104X156[4X fi;[104X157[4X [104X158[4X #=====# can only work for homalg internal matrices #=====#[104X159[4X [104X160[4X z := Zero( HomalgRing( C ) );[104X161[4X [104X162[4X ## copying the rows saves memory;[104X163[4X ## we assume that the entries are never modified!!![104X164[4X return homalgInternalMatrixHull([104X165[4X ListWithIdenticalEntries( NrRows( C ),[104X166[4X ListWithIdenticalEntries( NrColumns( C ), z ) ) );[104X167[4X [104X168[4Xend );[104X169[4X[32X[104X170171[1XC.4-4 Eval[101X172173[29X[2XEval[102X( [3XC[103X ) [32X method174[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X175176[33X[0;0YIn case the matrix [3XC[103X was created using [2XHomalgIdentityMatrix[102X ([14X5.2-4[114X) then the177filter [10XIsOne[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function (-->178[2XIdentityMatrix[102X ([14XB.1-4[114X)) will be used to set the attribute [10XEval[110X.[133X179180[4X[32X Code [32X[104X181[4XInstallMethod( Eval,[104X182[4X "for homalg matrices (IsOne)",[104X183[4X [ IsHomalgMatrix and IsOne and HasNrRows and HasNrColumns ], 10,[104X184[4X [104X185[4X function( C )[104X186[4X local R, id, RP, o, z, zz;[104X187[4X [104X188[4X R := HomalgRing( C );[104X189[4X [104X190[4X if IsBound( R!.IdentityMatrices ) then[104X191[4X id := ElmWPObj( R!.IdentityMatrices!.weak_pointers, NrColumns( C ) );[104X192[4X if id <> fail then[104X193[4X R!.IdentityMatrices!.cache_hits := R!.IdentityMatrices!.cache_hits + 1;[104X194[4X return id;[104X195[4X fi;[104X196[4X ## we do not count cache_misses as it is equivalent to counter[104X197[4X fi;[104X198[4X [104X199[4X RP := homalgTable( R );[104X200[4X [104X201[4X if IsBound( RP!.IdentityMatrix ) then[104X202[4X id := RP!.IdentityMatrix( C );[104X203[4X SetElmWPObj( R!.IdentityMatrices!.weak_pointers, NrColumns( C ), id );[104X204[4X R!.IdentityMatrices!.counter := R!.IdentityMatrices!.counter + 1;[104X205[4X return id;[104X206[4X fi;[104X207[4X [104X208[4X if not IsHomalgInternalMatrixRep( C ) then[104X209[4X Error( "could not find a procedure called IdentityMatrix ",[104X210[4X "homalgTable to evaluate a non-internal identity matrix\n" );[104X211[4X fi;[104X212[4X [104X213[4X #=====# can only work for homalg internal matrices #=====#[104X214[4X [104X215[4X z := Zero( HomalgRing( C ) );[104X216[4X o := One( HomalgRing( C ) );[104X217[4X [104X218[4X zz := ListWithIdenticalEntries( NrColumns( C ), z );[104X219[4X [104X220[4X id := List( [ 1 .. NrRows( C ) ],[104X221[4X function(i)[104X222[4X local z;[104X223[4X z := ShallowCopy( zz ); z[i] := o; return z;[104X224[4X end );[104X225[4X [104X226[4X id := homalgInternalMatrixHull( id );[104X227[4X [104X228[4X SetElmWPObj( R!.IdentityMatrices!.weak_pointers, NrColumns( C ), id );[104X229[4X [104X230[4X return id;[104X231[4X [104X232[4Xend );[104X233[4X[32X[104X234235[1XC.4-5 Eval[101X236237[29X[2XEval[102X( [3XLI[103X ) [32X method238[6XReturns:[106X [33X[0;10Ysee below[133X239240[33X[0;0YIn case the matrix [3XLI[103X was created using [2XLeftInverseLazy[102X ([14X5.5-4[114X) then the241filter [10XHasEvalLeftInverse[110X for [3XLI[103X is set to true and the method listed below242will be used to set the attribute [10XEval[110X. (--> [2XLeftInverse[102X ([14X5.5-2[114X))[133X243244[4X[32X Code [32X[104X245[4XInstallMethod( Eval,[104X246[4X "for homalg matrices",[104X247[4X [ IsHomalgMatrix and HasEvalLeftInverse ],[104X248[4X [104X249[4X function( LI )[104X250[4X local left_inv;[104X251[4X [104X252[4X left_inv := LeftInverse( EvalLeftInverse( LI ) );[104X253[4X [104X254[4X if IsBool( left_inv ) then[104X255[4X return false;[104X256[4X fi;[104X257[4X [104X258[4X return Eval( left_inv );[104X259[4X [104X260[4Xend );[104X261[4X[32X[104X262263[1XC.4-6 Eval[101X264265[29X[2XEval[102X( [3XRI[103X ) [32X method266[6XReturns:[106X [33X[0;10Ysee below[133X267268[33X[0;0YIn case the matrix [3XRI[103X was created using [2XRightInverseLazy[102X ([14X5.5-5[114X) then the269filter [10XHasEvalRightInverse[110X for [3XRI[103X is set to true and the method listed below270will be used to set the attribute [10XEval[110X. (--> [2XRightInverse[102X ([14X5.5-3[114X))[133X271272[4X[32X Code [32X[104X273[4XInstallMethod( Eval,[104X274[4X "for homalg matrices",[104X275[4X [ IsHomalgMatrix and HasEvalRightInverse ],[104X276[4X [104X277[4X function( RI )[104X278[4X local right_inv;[104X279[4X [104X280[4X right_inv := RightInverse( EvalRightInverse( RI ) );[104X281[4X [104X282[4X if IsBool( right_inv ) then[104X283[4X return false;[104X284[4X fi;[104X285[4X [104X286[4X return Eval( right_inv );[104X287[4X [104X288[4Xend );[104X289[4X[32X[104X290291[1XC.4-7 Eval[101X292293[29X[2XEval[102X( [3XC[103X ) [32X method294[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X295296[33X[0;0YIn case the matrix was created using [2XInvolution[102X ([14X5.5-6[114X) then the filter297[10XHasEvalInvolution[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function298[2XInvolution[102X ([14XB.1-5[114X) will be used to set the attribute [10XEval[110X.[133X299300[4X[32X Code [32X[104X301[4XInstallMethod( Eval,[104X302[4X "for homalg matrices (HasEvalInvolution)",[104X303[4X [ IsHomalgMatrix and HasEvalInvolution ],[104X304[4X [104X305[4X function( C )[104X306[4X local R, RP, M;[104X307[4X [104X308[4X R := HomalgRing( C );[104X309[4X [104X310[4X RP := homalgTable( R );[104X311[4X [104X312[4X M := EvalInvolution( C );[104X313[4X [104X314[4X if IsBound(RP!.Involution) then[104X315[4X return RP!.Involution( M );[104X316[4X fi;[104X317[4X [104X318[4X if not IsHomalgInternalMatrixRep( C ) then[104X319[4X Error( "could not find a procedure called Involution ",[104X320[4X "in the homalgTable of the non-internal ring\n" );[104X321[4X fi;[104X322[4X [104X323[4X #=====# can only work for homalg internal matrices #=====#[104X324[4X [104X325[4X return homalgInternalMatrixHull( TransposedMat( Eval( M )!.matrix ) );[104X326[4X [104X327[4Xend );[104X328[4X[32X[104X329330[1XC.4-8 Eval[101X331332[29X[2XEval[102X( [3XC[103X ) [32X method333[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X334335[33X[0;0YIn case the matrix was created using [2XCertainRows[102X ([14X5.5-7[114X) then the filter336[10XHasEvalCertainRows[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function337[2XCertainRows[102X ([14XB.1-6[114X) will be used to set the attribute [10XEval[110X.[133X338339[4X[32X Code [32X[104X340[4XInstallMethod( Eval,[104X341[4X "for homalg matrices (HasEvalCertainRows)",[104X342[4X [ IsHomalgMatrix and HasEvalCertainRows ],[104X343[4X [104X344[4X function( C )[104X345[4X local R, RP, e, M, plist;[104X346[4X [104X347[4X R := HomalgRing( C );[104X348[4X [104X349[4X RP := homalgTable( R );[104X350[4X [104X351[4X e := EvalCertainRows( C );[104X352[4X [104X353[4X M := e[1];[104X354[4X plist := e[2];[104X355[4X [104X356[4X if IsBound(RP!.CertainRows) then[104X357[4X return RP!.CertainRows( M, plist );[104X358[4X fi;[104X359[4X [104X360[4X if not IsHomalgInternalMatrixRep( C ) then[104X361[4X Error( "could not find a procedure called CertainRows ",[104X362[4X "in the homalgTable of the non-internal ring\n" );[104X363[4X fi;[104X364[4X [104X365[4X #=====# can only work for homalg internal matrices #=====#[104X366[4X [104X367[4X return homalgInternalMatrixHull( Eval( M )!.matrix{ plist } );[104X368[4X [104X369[4Xend );[104X370[4X[32X[104X371372[1XC.4-9 Eval[101X373374[29X[2XEval[102X( [3XC[103X ) [32X method375[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X376377[33X[0;0YIn case the matrix was created using [2XCertainColumns[102X ([14X5.5-8[114X) then the filter378[10XHasEvalCertainColumns[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function379[2XCertainColumns[102X ([14XB.1-7[114X) will be used to set the attribute [10XEval[110X.[133X380381[4X[32X Code [32X[104X382[4XInstallMethod( Eval,[104X383[4X "for homalg matrices (HasEvalCertainColumns)",[104X384[4X [ IsHomalgMatrix and HasEvalCertainColumns ],[104X385[4X [104X386[4X function( C )[104X387[4X local R, RP, e, M, plist;[104X388[4X [104X389[4X R := HomalgRing( C );[104X390[4X [104X391[4X RP := homalgTable( R );[104X392[4X [104X393[4X e := EvalCertainColumns( C );[104X394[4X [104X395[4X M := e[1];[104X396[4X plist := e[2];[104X397[4X [104X398[4X if IsBound(RP!.CertainColumns) then[104X399[4X return RP!.CertainColumns( M, plist );[104X400[4X fi;[104X401[4X [104X402[4X if not IsHomalgInternalMatrixRep( C ) then[104X403[4X Error( "could not find a procedure called CertainColumns ",[104X404[4X "in the homalgTable of the non-internal ring\n" );[104X405[4X fi;[104X406[4X [104X407[4X #=====# can only work for homalg internal matrices #=====#[104X408[4X [104X409[4X return homalgInternalMatrixHull([104X410[4X Eval( M )!.matrix{[ 1 .. NrRows( M ) ]}{plist} );[104X411[4X [104X412[4Xend );[104X413[4X[32X[104X414415[1XC.4-10 Eval[101X416417[29X[2XEval[102X( [3XC[103X ) [32X method418[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X419420[33X[0;0YIn case the matrix was created using [2XUnionOfRows[102X ([14X5.5-9[114X) then the filter421[10XHasEvalUnionOfRows[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function422[2XUnionOfRows[102X ([14XB.1-8[114X) will be used to set the attribute [10XEval[110X.[133X423424[4X[32X Code [32X[104X425[4XInstallMethod( Eval,[104X426[4X "for homalg matrices (HasEvalUnionOfRows)",[104X427[4X [ IsHomalgMatrix and HasEvalUnionOfRows ],[104X428[4X [104X429[4X function( C )[104X430[4X local R, RP, e, A, B, U;[104X431[4X [104X432[4X R := HomalgRing( C );[104X433[4X [104X434[4X RP := homalgTable( R );[104X435[4X [104X436[4X e := EvalUnionOfRows( C );[104X437[4X [104X438[4X A := e[1];[104X439[4X B := e[2];[104X440[4X [104X441[4X if IsBound(RP!.UnionOfRows) then[104X442[4X return RP!.UnionOfRows( A, B );[104X443[4X fi;[104X444[4X [104X445[4X if not IsHomalgInternalMatrixRep( C ) then[104X446[4X Error( "could not find a procedure called UnionOfRows ",[104X447[4X "in the homalgTable of the non-internal ring\n" );[104X448[4X fi;[104X449[4X [104X450[4X #=====# can only work for homalg internal matrices #=====#[104X451[4X [104X452[4X U := ShallowCopy( Eval( A )!.matrix );[104X453[4X [104X454[4X U{ [ NrRows( A ) + 1 .. NrRows( A ) + NrRows( B ) ] } := Eval( B )!.matrix;[104X455[4X [104X456[4X return homalgInternalMatrixHull( U );[104X457[4X [104X458[4Xend );[104X459[4X[32X[104X460461[1XC.4-11 Eval[101X462463[29X[2XEval[102X( [3XC[103X ) [32X method464[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X465466[33X[0;0YIn case the matrix was created using [2XUnionOfColumns[102X ([14X5.5-10[114X) then the filter467[10XHasEvalUnionOfColumns[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function468[2XUnionOfColumns[102X ([14XB.1-9[114X) will be used to set the attribute [10XEval[110X.[133X469470[4X[32X Code [32X[104X471[4XInstallMethod( Eval,[104X472[4X "for homalg matrices (HasEvalUnionOfColumns)",[104X473[4X [ IsHomalgMatrix and HasEvalUnionOfColumns ],[104X474[4X [104X475[4X function( C )[104X476[4X local R, RP, e, A, B, U;[104X477[4X [104X478[4X R := HomalgRing( C );[104X479[4X [104X480[4X RP := homalgTable( R );[104X481[4X [104X482[4X e := EvalUnionOfColumns( C );[104X483[4X [104X484[4X A := e[1];[104X485[4X B := e[2];[104X486[4X [104X487[4X if IsBound(RP!.UnionOfColumns) then[104X488[4X return RP!.UnionOfColumns( A, B );[104X489[4X fi;[104X490[4X [104X491[4X if not IsHomalgInternalMatrixRep( C ) then[104X492[4X Error( "could not find a procedure called UnionOfColumns ",[104X493[4X "in the homalgTable of the non-internal ring\n" );[104X494[4X fi;[104X495[4X [104X496[4X #=====# can only work for homalg internal matrices #=====#[104X497[4X [104X498[4X U := List( Eval( A )!.matrix, ShallowCopy );[104X499[4X [104X500[4X U{ [ 1 .. NrRows( A ) ] }[104X501[4X { [ NrColumns( A ) + 1 .. NrColumns( A ) + NrColumns( B ) ] }[104X502[4X := Eval( B )!.matrix;[104X503[4X [104X504[4X return homalgInternalMatrixHull( U );[104X505[4X [104X506[4Xend );[104X507[4X[32X[104X508509[1XC.4-12 Eval[101X510511[29X[2XEval[102X( [3XC[103X ) [32X method512[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X513514[33X[0;0YIn case the matrix was created using [2XDiagMat[102X ([14X5.5-11[114X) then the filter515[10XHasEvalDiagMat[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function [2XDiagMat[102X516([14XB.1-10[114X) will be used to set the attribute [10XEval[110X.[133X517518[4X[32X Code [32X[104X519[4XInstallMethod( Eval,[104X520[4X "for homalg matrices (HasEvalDiagMat)",[104X521[4X [ IsHomalgMatrix and HasEvalDiagMat ],[104X522[4X [104X523[4X function( C )[104X524[4X local R, RP, e, z, m, n, diag, mat;[104X525[4X [104X526[4X R := HomalgRing( C );[104X527[4X [104X528[4X RP := homalgTable( R );[104X529[4X [104X530[4X e := EvalDiagMat( C );[104X531[4X [104X532[4X if IsBound(RP!.DiagMat) then[104X533[4X return RP!.DiagMat( e );[104X534[4X fi;[104X535[4X [104X536[4X if not IsHomalgInternalMatrixRep( C ) then[104X537[4X Error( "could not find a procedure called DiagMat ",[104X538[4X "in the homalgTable of the non-internal ring\n" );[104X539[4X fi;[104X540[4X [104X541[4X #=====# can only work for homalg internal matrices #=====#[104X542[4X [104X543[4X z := Zero( R );[104X544[4X [104X545[4X m := Sum( List( e, NrRows ) );[104X546[4X n := Sum( List( e, NrColumns ) );[104X547[4X [104X548[4X diag := List( [ 1 .. m ], a -> List( [ 1 .. n ], b -> z ) );[104X549[4X [104X550[4X m := 0;[104X551[4X n := 0;[104X552[4X [104X553[4X for mat in e do[104X554[4X diag{ [ m + 1 .. m + NrRows( mat ) ] }{ [ n + 1 .. n + NrColumns( mat ) ] }[104X555[4X := Eval( mat )!.matrix;[104X556[4X [104X557[4X m := m + NrRows( mat );[104X558[4X n := n + NrColumns( mat );[104X559[4X od;[104X560[4X [104X561[4X return homalgInternalMatrixHull( diag );[104X562[4X [104X563[4Xend );[104X564[4X[32X[104X565566[1XC.4-13 Eval[101X567568[29X[2XEval[102X( [3XC[103X ) [32X method569[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X570571[33X[0;0YIn case the matrix was created using [2XKroneckerMat[102X ([14X5.5-12[114X) then the filter572[10XHasEvalKroneckerMat[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function573[2XKroneckerMat[102X ([14XB.1-11[114X) will be used to set the attribute [10XEval[110X.[133X574575[4X[32X Code [32X[104X576[4XInstallMethod( Eval,[104X577[4X "for homalg matrices (HasEvalKroneckerMat)",[104X578[4X [ IsHomalgMatrix and HasEvalKroneckerMat ],[104X579[4X [104X580[4X function( C )[104X581[4X local R, RP, A, B;[104X582[4X [104X583[4X R := HomalgRing( C );[104X584[4X [104X585[4X if ( HasIsCommutative( R ) and not IsCommutative( R ) ) and[104X586[4X ( HasIsSuperCommutative( R ) and not IsSuperCommutative( R ) ) then[104X587[4X Info( InfoWarning, 1, "\033[01m\033[5;31;47m",[104X588[4X "the Kronecker product is only defined for (super) commutative rings!",[104X589[4X "\033[0m" );[104X590[4X fi;[104X591[4X [104X592[4X RP := homalgTable( R );[104X593[4X [104X594[4X A := EvalKroneckerMat( C )[1];[104X595[4X B := EvalKroneckerMat( C )[2];[104X596[4X [104X597[4X if IsBound(RP!.KroneckerMat) then[104X598[4X return RP!.KroneckerMat( A, B );[104X599[4X fi;[104X600[4X [104X601[4X if not IsHomalgInternalMatrixRep( C ) then[104X602[4X Error( "could not find a procedure called KroneckerMat ",[104X603[4X "in the homalgTable of the non-internal ring\n" );[104X604[4X fi;[104X605[4X [104X606[4X #=====# can only work for homalg internal matrices #=====#[104X607[4X [104X608[4X return homalgInternalMatrixHull([104X609[4X KroneckerProduct( Eval( A )!.matrix, Eval( B )!.matrix ) );[104X610[4X ## this was easy, thanks GAP :)[104X611[4X [104X612[4Xend );[104X613[4X[32X[104X614615[1XC.4-14 Eval[101X616617[29X[2XEval[102X( [3XC[103X ) [32X method618[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X619620[33X[0;0YIn case the matrix was created using [2X\*[102X ([14X5.5-13[114X) then the filter621[10XHasEvalMulMat[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function [2XMulMat[102X622([14XB.1-12[114X) will be used to set the attribute [10XEval[110X.[133X623624[4X[32X Code [32X[104X625[4XInstallMethod( Eval,[104X626[4X "for homalg matrices (HasEvalMulMat)",[104X627[4X [ IsHomalgMatrix and HasEvalMulMat ],[104X628[4X [104X629[4X function( C )[104X630[4X local R, RP, e, a, A;[104X631[4X [104X632[4X R := HomalgRing( C );[104X633[4X [104X634[4X RP := homalgTable( R );[104X635[4X [104X636[4X e := EvalMulMat( C );[104X637[4X [104X638[4X a := e[1];[104X639[4X A := e[2];[104X640[4X [104X641[4X if IsBound(RP!.MulMat) then[104X642[4X return RP!.MulMat( a, A );[104X643[4X fi;[104X644[4X [104X645[4X if not IsHomalgInternalMatrixRep( C ) then[104X646[4X Error( "could not find a procedure called MulMat ",[104X647[4X "in the homalgTable of the non-internal ring\n" );[104X648[4X fi;[104X649[4X [104X650[4X #=====# can only work for homalg internal matrices #=====#[104X651[4X [104X652[4X return a * Eval( A );[104X653[4X [104X654[4Xend );[104X655[4X[104X656[4XInstallMethod( Eval,[104X657[4X "for homalg matrices (HasEvalMulMatRight)",[104X658[4X [ IsHomalgMatrix and HasEvalMulMatRight ],[104X659[4X [104X660[4X function( C )[104X661[4X local R, RP, e, A, a;[104X662[4X [104X663[4X R := HomalgRing( C );[104X664[4X [104X665[4X RP := homalgTable( R );[104X666[4X [104X667[4X e := EvalMulMatRight( C );[104X668[4X [104X669[4X A := e[1];[104X670[4X a := e[2];[104X671[4X [104X672[4X if IsBound(RP!.MulMatRight) then[104X673[4X return RP!.MulMatRight( A, a );[104X674[4X fi;[104X675[4X [104X676[4X if not IsHomalgInternalMatrixRep( C ) then[104X677[4X Error( "could not find a procedure called MulMatRight ",[104X678[4X "in the homalgTable of the non-internal ring\n" );[104X679[4X fi;[104X680[4X [104X681[4X #=====# can only work for homalg internal matrices #=====#[104X682[4X [104X683[4X return Eval( A ) * a;[104X684[4X [104X685[4Xend );[104X686[4X[32X[104X687688[1XC.4-15 Eval[101X689690[29X[2XEval[102X( [3XC[103X ) [32X method691[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X692693[33X[0;0YIn case the matrix was created using [2X\+[102X ([14X5.5-14[114X) then the filter694[10XHasEvalAddMat[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function [2XAddMat[102X695([14XB.1-13[114X) will be used to set the attribute [10XEval[110X.[133X696697[4X[32X Code [32X[104X698[4XInstallMethod( Eval,[104X699[4X "for homalg matrices (HasEvalAddMat)",[104X700[4X [ IsHomalgMatrix and HasEvalAddMat ],[104X701[4X [104X702[4X function( C )[104X703[4X local R, RP, e, A, B;[104X704[4X [104X705[4X R := HomalgRing( C );[104X706[4X [104X707[4X RP := homalgTable( R );[104X708[4X [104X709[4X e := EvalAddMat( C );[104X710[4X [104X711[4X A := e[1];[104X712[4X B := e[2];[104X713[4X [104X714[4X if IsBound(RP!.AddMat) then[104X715[4X return RP!.AddMat( A, B );[104X716[4X fi;[104X717[4X [104X718[4X if not IsHomalgInternalMatrixRep( C ) then[104X719[4X Error( "could not find a procedure called AddMat ",[104X720[4X "in the homalgTable of the non-internal ring\n" );[104X721[4X fi;[104X722[4X [104X723[4X #=====# can only work for homalg internal matrices #=====#[104X724[4X [104X725[4X return Eval( A ) + Eval( B );[104X726[4X [104X727[4Xend );[104X728[4X[32X[104X729730[1XC.4-16 Eval[101X731732[29X[2XEval[102X( [3XC[103X ) [32X method733[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X734735[33X[0;0YIn case the matrix was created using [2X\-[102X ([14X5.5-15[114X) then the filter736[10XHasEvalSubMat[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function [2XSubMat[102X737([14XB.1-14[114X) will be used to set the attribute [10XEval[110X.[133X738739[4X[32X Code [32X[104X740[4XInstallMethod( Eval,[104X741[4X "for homalg matrices (HasEvalSubMat)",[104X742[4X [ IsHomalgMatrix and HasEvalSubMat ],[104X743[4X [104X744[4X function( C )[104X745[4X local R, RP, e, A, B;[104X746[4X [104X747[4X R := HomalgRing( C );[104X748[4X [104X749[4X RP := homalgTable( R );[104X750[4X [104X751[4X e := EvalSubMat( C );[104X752[4X [104X753[4X A := e[1];[104X754[4X B := e[2];[104X755[4X [104X756[4X if IsBound(RP!.SubMat) then[104X757[4X return RP!.SubMat( A, B );[104X758[4X fi;[104X759[4X [104X760[4X if not IsHomalgInternalMatrixRep( C ) then[104X761[4X Error( "could not find a procedure called SubMat ",[104X762[4X "in the homalgTable of the non-internal ring\n" );[104X763[4X fi;[104X764[4X [104X765[4X #=====# can only work for homalg internal matrices #=====#[104X766[4X [104X767[4X return Eval( A ) - Eval( B );[104X768[4X [104X769[4Xend );[104X770[4X[32X[104X771772[1XC.4-17 Eval[101X773774[29X[2XEval[102X( [3XC[103X ) [32X method775[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X776777[33X[0;0YIn case the matrix was created using [2X\*[102X ([14X5.5-16[114X) then the filter778[10XHasEvalCompose[110X for [3XC[103X is set to true and the [10XhomalgTable[110X function [2XCompose[102X779([14XB.1-15[114X) will be used to set the attribute [10XEval[110X.[133X780781[4X[32X Code [32X[104X782[4XInstallMethod( Eval,[104X783[4X "for homalg matrices (HasEvalCompose)",[104X784[4X [ IsHomalgMatrix and HasEvalCompose ],[104X785[4X [104X786[4X function( C )[104X787[4X local R, RP, e, A, B;[104X788[4X [104X789[4X R := HomalgRing( C );[104X790[4X [104X791[4X RP := homalgTable( R );[104X792[4X [104X793[4X e := EvalCompose( C );[104X794[4X [104X795[4X A := e[1];[104X796[4X B := e[2];[104X797[4X [104X798[4X if IsBound(RP!.Compose) then[104X799[4X return RP!.Compose( A, B );[104X800[4X fi;[104X801[4X [104X802[4X if not IsHomalgInternalMatrixRep( C ) then[104X803[4X Error( "could not find a procedure called Compose ",[104X804[4X "in the homalgTable of the non-internal ring\n" );[104X805[4X fi;[104X806[4X [104X807[4X #=====# can only work for homalg internal matrices #=====#[104X808[4X [104X809[4X return Eval( A ) * Eval( B );[104X810[4X [104X811[4Xend );[104X812[4X[32X[104X813814815816