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[1XB [33X[0;0YThe Matrix Tool Operations[133X[101X23[33X[0;0YThe functions listed below are components of the [10XhomalgTable[110X object stored4in the ring. They are only indirectly accessible through standard methods5that invoke them.[133X678[1XB.1 [33X[0;0YThe Tool Operations [13Xwithout[113X[101X[1X a Fallback Method[133X[101X910[33X[0;0YThere are matrix methods for which [5Xhomalg[105X needs a [10XhomalgTable[110X entry for11non-internal rings, as it cannot provide a suitable fallback. Below is the12list of these [10XhomalgTable[110X entries.[133X1314[1XB.1-1 InitialMatrix[101X1516[29X[2XInitialMatrix[102X( [3XC[103X ) [32X function17[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X1819[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X20component [22XRP[122X!.[10XInitialMatrix[110X is bound then the method [2XEval[102X ([14XC.4-1[114X) resets the21filter [10XIsInitialMatrix[110X and returns [22XRP[122X!.[10XInitialMatrix[110X[22X( [3XC[103X )[122X.[133X2223[1XB.1-2 InitialIdentityMatrix[101X2425[29X[2XInitialIdentityMatrix[102X( [3XC[103X ) [32X function26[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X2728[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X29component [22XRP[122X!.[10XInitialIdentityMatrix[110X is bound then the method [2XEval[102X ([14XC.4-2[114X)30resets the filter [10XIsInitialIdentityMatrix[110X and returns31[22XRP[122X!.[10XInitialIdentityMatrix[110X[22X( [3XC[103X )[122X.[133X3233[1XB.1-3 ZeroMatrix[101X3435[29X[2XZeroMatrix[102X( [3XC[103X ) [32X function36[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X3738[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X39component [22XRP[122X!.[10XZeroMatrix[110X is bound then the method [2XEval[102X ([14XC.4-3[114X) returns40[22XRP[122X!.[10XZeroMatrix[110X[22X( [3XC[103X )[122X.[133X4142[1XB.1-4 IdentityMatrix[101X4344[29X[2XIdentityMatrix[102X( [3XC[103X ) [32X function45[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X4647[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X48component [22XRP[122X!.[10XIdentityMatrix[110X is bound then the method [2XEval[102X ([14XC.4-4[114X) returns49[22XRP[122X!.[10XIdentityMatrix[110X[22X( [3XC[103X )[122X.[133X5051[1XB.1-5 Involution[101X5253[29X[2XInvolution[102X( [3XM[103X ) [32X function54[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X5556[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X57component [22XRP[122X!.[10XInvolution[110X is bound then the method [2XEval[102X ([14XC.4-7[114X) returns58[22XRP[122X!.[10XInvolution[110X applied to the content of the attribute [10XEvalInvolution[110X[22X( [3XC[103X ) =59[3XM[103X[122X.[133X6061[1XB.1-6 CertainRows[101X6263[29X[2XCertainRows[102X( [3XM[103X, [3Xplist[103X ) [32X function64[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X6566[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X67component [22XRP[122X!.[10XCertainRows[110X is bound then the method [2XEval[102X ([14XC.4-8[114X) returns68[22XRP[122X!.[10XCertainRows[110X applied to the content of the attribute [10XEvalCertainRows[110X[22X( [3XC[103X )69= [ [3XM[103X, [3Xplist[103X ][122X.[133X7071[1XB.1-7 CertainColumns[101X7273[29X[2XCertainColumns[102X( [3XM[103X, [3Xplist[103X ) [32X function74[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X7576[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X77component [22XRP[122X!.[10XCertainColumns[110X is bound then the method [2XEval[102X ([14XC.4-9[114X) returns78[22XRP[122X!.[10XCertainColumns[110X applied to the content of the attribute79[10XEvalCertainColumns[110X[22X( [3XC[103X ) = [ [3XM[103X, [3Xplist[103X ][122X.[133X8081[1XB.1-8 UnionOfRows[101X8283[29X[2XUnionOfRows[102X( [3XA[103X, [3XB[103X ) [32X function84[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X8586[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X87component [22XRP[122X!.[10XUnionOfRows[110X is bound then the method [2XEval[102X ([14XC.4-10[114X) returns88[22XRP[122X!.[10XUnionOfRows[110X applied to the content of the attribute [10XEvalUnionOfRows[110X[22X( [3XC[103X )89= [ [3XA[103X, [3XB[103X ][122X.[133X9091[1XB.1-9 UnionOfColumns[101X9293[29X[2XUnionOfColumns[102X( [3XA[103X, [3XB[103X ) [32X function94[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X9596[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X97component [22XRP[122X!.[10XUnionOfColumns[110X is bound then the method [2XEval[102X ([14XC.4-11[114X) returns98[22XRP[122X!.[10XUnionOfColumns[110X applied to the content of the attribute99[10XEvalUnionOfColumns[110X[22X( [3XC[103X ) = [ [3XA[103X, [3XB[103X ][122X.[133X100101[1XB.1-10 DiagMat[101X102103[29X[2XDiagMat[102X( [3Xe[103X ) [32X function104[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X105106[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X107component [22XRP[122X!.[10XDiagMat[110X is bound then the method [2XEval[102X ([14XC.4-12[114X) returns108[22XRP[122X!.[10XDiagMat[110X applied to the content of the attribute [10XEvalDiagMat[110X[22X( [3XC[103X ) = [3Xe[103X[122X.[133X109110[1XB.1-11 KroneckerMat[101X111112[29X[2XKroneckerMat[102X( [3XA[103X, [3XB[103X ) [32X function113[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X114115[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X116component [22XRP[122X!.[10XKroneckerMat[110X is bound then the method [2XEval[102X ([14XC.4-13[114X) returns117[22XRP[122X!.[10XKroneckerMat[110X applied to the content of the attribute [10XEvalKroneckerMat[110X[22X( [3XC[103X118) = [ [3XA[103X, [3XB[103X ][122X.[133X119120[1XB.1-12 MulMat[101X121122[29X[2XMulMat[102X( [3Xa[103X, [3XA[103X ) [32X function123[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X124125[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X126component [22XRP[122X!.[10XMulMat[110X is bound then the method [2XEval[102X ([14XC.4-14[114X) returns127[22XRP[122X!.[10XMulMat[110X applied to the content of the attribute [10XEvalMulMat[110X[22X( [3XC[103X ) = [ [3Xa[103X, [3XA[103X128][122X.[133X129130[1XB.1-13 AddMat[101X131132[29X[2XAddMat[102X( [3XA[103X, [3XB[103X ) [32X function133[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X134135[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X136component [22XRP[122X!.[10XAddMat[110X is bound then the method [2XEval[102X ([14XC.4-15[114X) returns137[22XRP[122X!.[10XAddMat[110X applied to the content of the attribute [10XEvalAddMat[110X[22X( [3XC[103X ) = [ [3XA[103X, [3XB[103X138][122X.[133X139140[1XB.1-14 SubMat[101X141142[29X[2XSubMat[102X( [3XA[103X, [3XB[103X ) [32X function143[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X144145[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X146component [22XRP[122X!.[10XSubMat[110X is bound then the method [2XEval[102X ([14XC.4-16[114X) returns147[22XRP[122X!.[10XSubMat[110X applied to the content of the attribute [10XEvalSubMat[110X[22X( [3XC[103X ) = [ [3XA[103X, [3XB[103X148][122X.[133X149150[1XB.1-15 Compose[101X151152[29X[2XCompose[102X( [3XA[103X, [3XB[103X ) [32X function153[6XReturns:[106X [33X[0;10Ythe [10XEval[110X value of a [5Xhomalg[105X matrix [3XC[103X[133X154155[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X156component [22XRP[122X!.[10XCompose[110X is bound then the method [2XEval[102X ([14XC.4-17[114X) returns157[22XRP[122X!.[10XCompose[110X applied to the content of the attribute [10XEvalCompose[110X[22X( [3XC[103X ) = [ [3XA[103X,158[3XB[103X ][122X.[133X159160[1XB.1-16 IsZeroMatrix[101X161162[29X[2XIsZeroMatrix[102X( [3XM[103X ) [32X function163[6XReturns:[106X [33X[0;10Y[10Xtrue[110X or [10Xfalse[110X[133X164165[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XM[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X166component [22XRP[122X!.[10XIsZeroMatrix[110X is bound then the standard method for the167property [2XIsZero[102X ([14X5.3-1[114X) shown below returns [22XRP[122X!.[10XIsZeroMatrix[110X[22X( [3XM[103X )[122X.[133X168169[4X[32X Code [32X[104X170[4XInstallMethod( IsZero,[104X171[4X "for homalg matrices",[104X172[4X [ IsHomalgMatrix ],[104X173[4X [104X174[4X function( M )[104X175[4X local R, RP;[104X176[4X [104X177[4X R := HomalgRing( M );[104X178[4X [104X179[4X RP := homalgTable( R );[104X180[4X [104X181[4X if IsBound(RP!.IsZeroMatrix) then[104X182[4X ## CAUTION: the external system must be able[104X183[4X ## to check zero modulo possible ring relations![104X184[4X [104X185[4X return RP!.IsZeroMatrix( M ); ## with this, \= can fall back to IsZero[104X186[4X fi;[104X187[4X [104X188[4X #=====# the fallback method #=====#[104X189[4X [104X190[4X ## from the GAP4 documentation: ?Zero[104X191[4X ## `ZeroSameMutability( <obj> )' is equivalent to `0 * <obj>'.[104X192[4X [104X193[4X return M = 0 * M; ## hence, by default, IsZero falls back to \= (see below)[104X194[4X [104X195[4Xend );[104X196[4X[32X[104X197198[1XB.1-17 NrRows[101X199200[29X[2XNrRows[102X( [3XC[103X ) [32X function201[6XReturns:[106X [33X[0;10Ya nonnegative integer[133X202203[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X204component [22XRP[122X!.[10XNrRows[110X is bound then the standard method for the attribute205[2XNrRows[102X ([14X5.4-1[114X) shown below returns [22XRP[122X!.[10XNrRows[110X[22X( [3XC[103X )[122X.[133X206207[4X[32X Code [32X[104X208[4XInstallMethod( NrRows,[104X209[4X "for homalg matrices",[104X210[4X [ IsHomalgMatrix ],[104X211[4X [104X212[4X function( C )[104X213[4X local R, RP;[104X214[4X [104X215[4X R := HomalgRing( C );[104X216[4X [104X217[4X RP := homalgTable( R );[104X218[4X [104X219[4X if IsBound(RP!.NrRows) then[104X220[4X return RP!.NrRows( C );[104X221[4X fi;[104X222[4X [104X223[4X if not IsHomalgInternalMatrixRep( C ) then[104X224[4X Error( "could not find a procedure called NrRows ",[104X225[4X "in the homalgTable of the non-internal ring\n" );[104X226[4X fi;[104X227[4X [104X228[4X #=====# can only work for homalg internal matrices #=====#[104X229[4X [104X230[4X return Length( Eval( C )!.matrix );[104X231[4X [104X232[4Xend );[104X233[4X[32X[104X234235[1XB.1-18 NrColumns[101X236237[29X[2XNrColumns[102X( [3XC[103X ) [32X function238[6XReturns:[106X [33X[0;10Ya nonnegative integer[133X239240[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X241component [22XRP[122X!.[10XNrColumns[110X is bound then the standard method for the attribute242[2XNrColumns[102X ([14X5.4-2[114X) shown below returns [22XRP[122X!.[10XNrColumns[110X[22X( [3XC[103X )[122X.[133X243244[4X[32X Code [32X[104X245[4XInstallMethod( NrColumns,[104X246[4X "for homalg matrices",[104X247[4X [ IsHomalgMatrix ],[104X248[4X [104X249[4X function( C )[104X250[4X local R, RP;[104X251[4X [104X252[4X R := HomalgRing( C );[104X253[4X [104X254[4X RP := homalgTable( R );[104X255[4X [104X256[4X if IsBound(RP!.NrColumns) then[104X257[4X return RP!.NrColumns( C );[104X258[4X fi;[104X259[4X [104X260[4X if not IsHomalgInternalMatrixRep( C ) then[104X261[4X Error( "could not find a procedure called NrColumns ",[104X262[4X "in the homalgTable of the non-internal ring\n" );[104X263[4X fi;[104X264[4X [104X265[4X #=====# can only work for homalg internal matrices #=====#[104X266[4X [104X267[4X return Length( Eval( C )!.matrix[ 1 ] );[104X268[4X [104X269[4Xend );[104X270[4X[32X[104X271272[1XB.1-19 Determinant[101X273274[29X[2XDeterminant[102X( [3XC[103X ) [32X function275[6XReturns:[106X [33X[0;10Ya ring element[133X276277[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X278component [22XRP[122X!.[10XDeterminant[110X is bound then the standard method for the279attribute [2XDeterminantMat[102X ([14X5.4-3[114X) shown below returns [22XRP[122X!.[10XDeterminant[110X[22X( [3XC[103X )[122X.[133X280281[4X[32X Code [32X[104X282[4XInstallMethod( DeterminantMat,[104X283[4X "for homalg matrices",[104X284[4X [ IsHomalgMatrix ],[104X285[4X [104X286[4X function( C )[104X287[4X local R, RP;[104X288[4X [104X289[4X R := HomalgRing( C );[104X290[4X [104X291[4X RP := homalgTable( R );[104X292[4X [104X293[4X if NrRows( C ) <> NrColumns( C ) then[104X294[4X Error( "the matrix is not a square matrix\n" );[104X295[4X fi;[104X296[4X [104X297[4X if IsEmptyMatrix( C ) then[104X298[4X return One( R );[104X299[4X elif IsZero( C ) then[104X300[4X return Zero( R );[104X301[4X fi;[104X302[4X [104X303[4X if IsBound(RP!.Determinant) then[104X304[4X return RingElementConstructor( R )( RP!.Determinant( C ), R );[104X305[4X fi;[104X306[4X [104X307[4X if not IsHomalgInternalMatrixRep( C ) then[104X308[4X Error( "could not find a procedure called Determinant ",[104X309[4X "in the homalgTable of the non-internal ring\n" );[104X310[4X fi;[104X311[4X [104X312[4X #=====# can only work for homalg internal matrices #=====#[104X313[4X [104X314[4X return Determinant( Eval( C )!.matrix );[104X315[4X [104X316[4Xend );[104X317[4X[104X318[4X[104X319[4XInstallMethod( Determinant,[104X320[4X "for homalg matrices",[104X321[4X [ IsHomalgMatrix ],[104X322[4X [104X323[4X function( C )[104X324[4X [104X325[4X return DeterminantMat( C );[104X326[4X [104X327[4Xend );[104X328[4X[32X[104X329330331[1XB.2 [33X[0;0YThe Tool Operations with a Fallback Method[133X[101X332333[33X[0;0YThese are the methods for which it is recommended for performance reasons to334have a [10XhomalgTable[110X entry for non-internal rings. [5Xhomalg[105X only provides a335generic fallback method.[133X336337[1XB.2-1 AreEqualMatrices[101X338339[29X[2XAreEqualMatrices[102X( [3XM1[103X, [3XM2[103X ) [32X function340[6XReturns:[106X [33X[0;10Y[10Xtrue[110X or [10Xfalse[110X[133X341342[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XM1[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X343component [22XRP[122X!.[10XAreEqualMatrices[110X is bound then the standard method for the344operation [2X\=[102X ([14X5.5-17[114X) shown below returns [22XRP[122X!.[10XAreEqualMatrices[110X[22X( [3XM1[103X, [3XM2[103X )[122X.[133X345346[4X[32X Code [32X[104X347[4XInstallMethod( \=,[104X348[4X "for homalg comparable matrices",[104X349[4X [ IsHomalgMatrix, IsHomalgMatrix ],[104X350[4X [104X351[4X function( M1, M2 )[104X352[4X local R, RP, are_equal;[104X353[4X [104X354[4X ## do not touch mutable matrices[104X355[4X if not ( IsMutable( M1 ) or IsMutable( M2 ) ) then[104X356[4X [104X357[4X if IsBound( M1!.AreEqual ) then[104X358[4X are_equal := _ElmWPObj_ForHomalg( M1!.AreEqual, M2, fail );[104X359[4X if are_equal <> fail then[104X360[4X return are_equal;[104X361[4X fi;[104X362[4X else[104X363[4X M1!.AreEqual :=[104X364[4X ContainerForWeakPointers([104X365[4X TheTypeContainerForWeakPointersOnComputedValues,[104X366[4X [ "operation", "AreEqual" ] );[104X367[4X fi;[104X368[4X [104X369[4X if IsBound( M2!.AreEqual ) then[104X370[4X are_equal := _ElmWPObj_ForHomalg( M2!.AreEqual, M1, fail );[104X371[4X if are_equal <> fail then[104X372[4X return are_equal;[104X373[4X fi;[104X374[4X fi;[104X375[4X ## do not store things symmetrically below to ``save'' memory[104X376[4X [104X377[4X fi;[104X378[4X [104X379[4X R := HomalgRing( M1 );[104X380[4X [104X381[4X RP := homalgTable( R );[104X382[4X [104X383[4X if IsBound(RP!.AreEqualMatrices) then[104X384[4X ## CAUTION: the external system must be able to check equality[104X385[4X ## modulo possible ring relations (known to the external system)![104X386[4X are_equal := RP!.AreEqualMatrices( M1, M2 );[104X387[4X elif IsBound(RP!.Equal) then[104X388[4X ## CAUTION: the external system must be able to check equality[104X389[4X ## modulo possible ring relations (known to the external system)![104X390[4X are_equal := RP!.Equal( M1, M2 );[104X391[4X elif IsBound(RP!.IsZeroMatrix) then ## ensuring this avoids infinite loops[104X392[4X are_equal := IsZero( M1 - M2 );[104X393[4X fi;[104X394[4X [104X395[4X if IsBound( are_equal ) then[104X396[4X [104X397[4X ## do not touch mutable matrices[104X398[4X if not ( IsMutable( M1 ) or IsMutable( M2 ) ) then[104X399[4X [104X400[4X if are_equal then[104X401[4X MatchPropertiesAndAttributes( M1, M2,[104X402[4X LIMAT.intrinsic_properties,[104X403[4X LIMAT.intrinsic_attributes,[104X404[4X LIMAT.intrinsic_components[104X405[4X );[104X406[4X fi;[104X407[4X [104X408[4X ## do not store things symmetrically to ``save'' memory[104X409[4X _AddTwoElmWPObj_ForHomalg( M1!.AreEqual, M2, are_equal );[104X410[4X [104X411[4X fi;[104X412[4X [104X413[4X return are_equal;[104X414[4X fi;[104X415[4X [104X416[4X TryNextMethod( );[104X417[4X [104X418[4Xend );[104X419[4X[32X[104X420421[1XB.2-2 IsIdentityMatrix[101X422423[29X[2XIsIdentityMatrix[102X( [3XM[103X ) [32X function424[6XReturns:[106X [33X[0;10Y[10Xtrue[110X or [10Xfalse[110X[133X425426[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XM[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X427component [22XRP[122X!.[10XIsIdentityMatrix[110X is bound then the standard method for the428property [2XIsOne[102X ([14X5.3-2[114X) shown below returns [22XRP[122X!.[10XIsIdentityMatrix[110X[22X( [3XM[103X )[122X.[133X429430[4X[32X Code [32X[104X431[4XInstallMethod( IsOne,[104X432[4X "for homalg matrices",[104X433[4X [ IsHomalgMatrix ],[104X434[4X [104X435[4X function( M )[104X436[4X local R, RP;[104X437[4X [104X438[4X if NrRows( M ) <> NrColumns( M ) then[104X439[4X return false;[104X440[4X fi;[104X441[4X [104X442[4X R := HomalgRing( M );[104X443[4X [104X444[4X RP := homalgTable( R );[104X445[4X [104X446[4X if IsBound(RP!.IsIdentityMatrix) then[104X447[4X return RP!.IsIdentityMatrix( M );[104X448[4X fi;[104X449[4X [104X450[4X #=====# the fallback method #=====#[104X451[4X [104X452[4X return M = HomalgIdentityMatrix( NrRows( M ), HomalgRing( M ) );[104X453[4X [104X454[4Xend );[104X455[4X[32X[104X456457[1XB.2-3 IsDiagonalMatrix[101X458459[29X[2XIsDiagonalMatrix[102X( [3XM[103X ) [32X function460[6XReturns:[106X [33X[0;10Y[10Xtrue[110X or [10Xfalse[110X[133X461462[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XM[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X463component [22XRP[122X!.[10XIsDiagonalMatrix[110X is bound then the standard method for the464property [2XIsDiagonalMatrix[102X ([14X5.3-13[114X) shown below returns [22XRP[122X!.[10XIsDiagonalMatrix[110X[22X(465[3XM[103X )[122X.[133X466467[4X[32X Code [32X[104X468[4XInstallMethod( IsDiagonalMatrix,[104X469[4X "for homalg matrices",[104X470[4X [ IsHomalgMatrix ],[104X471[4X [104X472[4X function( M )[104X473[4X local R, RP, diag;[104X474[4X [104X475[4X R := HomalgRing( M );[104X476[4X [104X477[4X RP := homalgTable( R );[104X478[4X [104X479[4X if IsBound(RP!.IsDiagonalMatrix) then[104X480[4X return RP!.IsDiagonalMatrix( M );[104X481[4X fi;[104X482[4X [104X483[4X #=====# the fallback method #=====#[104X484[4X [104X485[4X diag := DiagonalEntries( M );[104X486[4X [104X487[4X return M = HomalgDiagonalMatrix( diag, NrRows( M ), NrColumns( M ), R );[104X488[4X [104X489[4Xend );[104X490[4X[32X[104X491492[1XB.2-4 ZeroRows[101X493494[29X[2XZeroRows[102X( [3XC[103X ) [32X function495[6XReturns:[106X [33X[0;10Ya (possibly empty) list of positive integers[133X496497[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X498component [22XRP[122X!.[10XZeroRows[110X is bound then the standard method of the attribute499[2XZeroRows[102X ([14X5.4-4[114X) shown below returns [22XRP[122X!.[10XZeroRows[110X[22X( [3XC[103X )[122X.[133X500501[4X[32X Code [32X[104X502[4XInstallMethod( ZeroRows,[104X503[4X "for homalg matrices",[104X504[4X [ IsHomalgMatrix ],[104X505[4X [104X506[4X function( C )[104X507[4X local R, RP, z;[104X508[4X [104X509[4X R := HomalgRing( C );[104X510[4X [104X511[4X RP := homalgTable( R );[104X512[4X [104X513[4X if IsBound(RP!.ZeroRows) then[104X514[4X return RP!.ZeroRows( C );[104X515[4X fi;[104X516[4X [104X517[4X #=====# the fallback method #=====#[104X518[4X [104X519[4X z := HomalgZeroMatrix( 1, NrColumns( C ), R );[104X520[4X [104X521[4X return Filtered( [ 1 .. NrRows( C ) ], a -> CertainRows( C, [ a ] ) = z );[104X522[4X [104X523[4Xend );[104X524[4X[32X[104X525526[1XB.2-5 ZeroColumns[101X527528[29X[2XZeroColumns[102X( [3XC[103X ) [32X function529[6XReturns:[106X [33X[0;10Ya (possibly empty) list of positive integers[133X530531[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XC[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X532component [22XRP[122X!.[10XZeroColumns[110X is bound then the standard method of the attribute533[2XZeroColumns[102X ([14X5.4-5[114X) shown below returns [22XRP[122X!.[10XZeroColumns[110X[22X( [3XC[103X )[122X.[133X534535[4X[32X Code [32X[104X536[4XInstallMethod( ZeroColumns,[104X537[4X "for homalg matrices",[104X538[4X [ IsHomalgMatrix ],[104X539[4X [104X540[4X function( C )[104X541[4X local R, RP, z;[104X542[4X [104X543[4X R := HomalgRing( C );[104X544[4X [104X545[4X RP := homalgTable( R );[104X546[4X [104X547[4X if IsBound(RP!.ZeroColumns) then[104X548[4X return RP!.ZeroColumns( C );[104X549[4X fi;[104X550[4X [104X551[4X #=====# the fallback method #=====#[104X552[4X [104X553[4X z := HomalgZeroMatrix( NrRows( C ), 1, R );[104X554[4X [104X555[4X return Filtered( [ 1 .. NrColumns( C ) ], a -> CertainColumns( C, [ a ] ) = z );[104X556[4X [104X557[4Xend );[104X558[4X[32X[104X559560[1XB.2-6 GetColumnIndependentUnitPositions[101X561562[29X[2XGetColumnIndependentUnitPositions[102X( [3XM[103X, [3Xposlist[103X ) [32X function563[6XReturns:[106X [33X[0;10Ya (possibly empty) list of pairs of positive integers[133X564565[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XM[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X566component [22XRP[122X!.[10XGetColumnIndependentUnitPositions[110X is bound then the standard567method of the operation [2XGetColumnIndependentUnitPositions[102X ([14X5.5-18[114X) shown568below returns [22XRP[122X!.[10XGetColumnIndependentUnitPositions[110X[22X( [3XM[103X, [3Xposlist[103X )[122X.[133X569570[4X[32X Code [32X[104X571[4XInstallMethod( GetColumnIndependentUnitPositions,[104X572[4X "for homalg matrices",[104X573[4X [ IsHomalgMatrix, IsHomogeneousList ],[104X574[4X [104X575[4X function( M, poslist )[104X576[4X local cache, R, RP, rest, pos, i, j, k;[104X577[4X [104X578[4X if IsBound( M!.GetColumnIndependentUnitPositions ) then[104X579[4X cache := M!.GetColumnIndependentUnitPositions;[104X580[4X if IsBound( cache.(String( poslist )) ) then[104X581[4X return cache.(String( poslist ));[104X582[4X fi;[104X583[4X else[104X584[4X cache := rec( );[104X585[4X M!.GetColumnIndependentUnitPositions := cache;[104X586[4X fi;[104X587[4X [104X588[4X R := HomalgRing( M );[104X589[4X [104X590[4X RP := homalgTable( R );[104X591[4X [104X592[4X if IsBound(RP!.GetColumnIndependentUnitPositions) then[104X593[4X pos := RP!.GetColumnIndependentUnitPositions( M, poslist );[104X594[4X if pos <> [ ] then[104X595[4X SetIsZero( M, false );[104X596[4X fi;[104X597[4X cache.(String( poslist )) := pos;[104X598[4X return pos;[104X599[4X fi;[104X600[4X [104X601[4X #=====# the fallback method #=====#[104X602[4X [104X603[4X rest := [ 1 .. NrColumns( M ) ];[104X604[4X [104X605[4X pos := [ ];[104X606[4X [104X607[4X for i in [ 1 .. NrRows( M ) ] do[104X608[4X for k in Reversed( rest ) do[104X609[4X if not [ i, k ] in poslist and[104X610[4X IsUnit( R, MatElm( M, i, k ) ) then[104X611[4X Add( pos, [ i, k ] );[104X612[4X rest := Filtered( rest,[104X613[4X a -> IsZero( MatElm( M, i, a ) ) );[104X614[4X break;[104X615[4X fi;[104X616[4X od;[104X617[4X od;[104X618[4X [104X619[4X if pos <> [ ] then[104X620[4X SetIsZero( M, false );[104X621[4X fi;[104X622[4X [104X623[4X cache.(String( poslist )) := pos;[104X624[4X [104X625[4X return pos;[104X626[4X [104X627[4Xend );[104X628[4X[32X[104X629630[1XB.2-7 GetRowIndependentUnitPositions[101X631632[29X[2XGetRowIndependentUnitPositions[102X( [3XM[103X, [3Xposlist[103X ) [32X function633[6XReturns:[106X [33X[0;10Ya (possibly empty) list of pairs of positive integers[133X634635[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XM[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X636component [22XRP[122X!.[10XGetRowIndependentUnitPositions[110X is bound then the standard637method of the operation [2XGetRowIndependentUnitPositions[102X ([14X5.5-19[114X) shown below638returns [22XRP[122X!.[10XGetRowIndependentUnitPositions[110X[22X( [3XM[103X, [3Xposlist[103X )[122X.[133X639640[4X[32X Code [32X[104X641[4XInstallMethod( GetRowIndependentUnitPositions,[104X642[4X "for homalg matrices",[104X643[4X [ IsHomalgMatrix, IsHomogeneousList ],[104X644[4X [104X645[4X function( M, poslist )[104X646[4X local cache, R, RP, rest, pos, j, i, k;[104X647[4X [104X648[4X if IsBound( M!.GetRowIndependentUnitPositions ) then[104X649[4X cache := M!.GetRowIndependentUnitPositions;[104X650[4X if IsBound( cache.(String( poslist )) ) then[104X651[4X return cache.(String( poslist ));[104X652[4X fi;[104X653[4X else[104X654[4X cache := rec( );[104X655[4X M!.GetRowIndependentUnitPositions := cache;[104X656[4X fi;[104X657[4X [104X658[4X R := HomalgRing( M );[104X659[4X [104X660[4X RP := homalgTable( R );[104X661[4X [104X662[4X if IsBound(RP!.GetRowIndependentUnitPositions) then[104X663[4X pos := RP!.GetRowIndependentUnitPositions( M, poslist );[104X664[4X if pos <> [ ] then[104X665[4X SetIsZero( M, false );[104X666[4X fi;[104X667[4X cache.( String( poslist ) ) := pos;[104X668[4X return pos;[104X669[4X fi;[104X670[4X [104X671[4X #=====# the fallback method #=====#[104X672[4X [104X673[4X rest := [ 1 .. NrRows( M ) ];[104X674[4X [104X675[4X pos := [ ];[104X676[4X [104X677[4X for j in [ 1 .. NrColumns( M ) ] do[104X678[4X for k in Reversed( rest ) do[104X679[4X if not [ j, k ] in poslist and[104X680[4X IsUnit( R, MatElm( M, k, j ) ) then[104X681[4X Add( pos, [ j, k ] );[104X682[4X rest := Filtered( rest,[104X683[4X a -> IsZero( MatElm( M, a, j ) ) );[104X684[4X break;[104X685[4X fi;[104X686[4X od;[104X687[4X od;[104X688[4X [104X689[4X if pos <> [ ] then[104X690[4X SetIsZero( M, false );[104X691[4X fi;[104X692[4X [104X693[4X cache.( String( poslist ) ) := pos;[104X694[4X [104X695[4X return pos;[104X696[4X [104X697[4Xend );[104X698[4X[32X[104X699700[1XB.2-8 GetUnitPosition[101X701702[29X[2XGetUnitPosition[102X( [3XM[103X, [3Xposlist[103X ) [32X function703[6XReturns:[106X [33X[0;10Ya (possibly empty) list of pairs of positive integers[133X704705[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XM[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X706component [22XRP[122X!.[10XGetUnitPosition[110X is bound then the standard method of the707operation [2XGetUnitPosition[102X ([14X5.5-20[114X) shown below returns [22XRP[122X!.[10XGetUnitPosition[110X[22X(708[3XM[103X, [3Xposlist[103X )[122X.[133X709710[4X[32X Code [32X[104X711[4XInstallMethod( GetUnitPosition,[104X712[4X "for homalg matrices",[104X713[4X [ IsHomalgMatrix, IsHomogeneousList ],[104X714[4X [104X715[4X function( M, poslist )[104X716[4X local R, RP, pos, m, n, i, j;[104X717[4X [104X718[4X R := HomalgRing( M );[104X719[4X [104X720[4X RP := homalgTable( R );[104X721[4X [104X722[4X if IsBound(RP!.GetUnitPosition) then[104X723[4X pos := RP!.GetUnitPosition( M, poslist );[104X724[4X if IsList( pos ) and IsPosInt( pos[1] ) and IsPosInt( pos[2] ) then[104X725[4X SetIsZero( M, false );[104X726[4X fi;[104X727[4X return pos;[104X728[4X fi;[104X729[4X [104X730[4X #=====# the fallback method #=====#[104X731[4X [104X732[4X m := NrRows( M );[104X733[4X n := NrColumns( M );[104X734[4X [104X735[4X for i in [ 1 .. m ] do[104X736[4X for j in [ 1 .. n ] do[104X737[4X if not [ i, j ] in poslist and not j in poslist and[104X738[4X IsUnit( R, MatElm( M, i, j ) ) then[104X739[4X SetIsZero( M, false );[104X740[4X return [ i, j ];[104X741[4X fi;[104X742[4X od;[104X743[4X od;[104X744[4X [104X745[4X return fail;[104X746[4X [104X747[4Xend );[104X748[4X[32X[104X749750[1XB.2-9 PositionOfFirstNonZeroEntryPerRow[101X751752[29X[2XPositionOfFirstNonZeroEntryPerRow[102X( [3XM[103X, [3Xposlist[103X ) [32X function753[6XReturns:[106X [33X[0;10Ya list of nonnegative integers[133X754755[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XM[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X756component [22XRP[122X!.[10XPositionOfFirstNonZeroEntryPerRow[110X is bound then the standard757method of the attribute [2XPositionOfFirstNonZeroEntryPerRow[102X ([14X5.4-8[114X) shown758below returns [22XRP[122X!.[10XPositionOfFirstNonZeroEntryPerRow[110X[22X( [3XM[103X )[122X.[133X759760[4X[32X Code [32X[104X761[4XInstallMethod( PositionOfFirstNonZeroEntryPerRow,[104X762[4X "for homalg matrices",[104X763[4X [ IsHomalgMatrix ],[104X764[4X [104X765[4X function( M )[104X766[4X local R, RP, pos, entries, r, c, i, k, j;[104X767[4X [104X768[4X R := HomalgRing( M );[104X769[4X [104X770[4X RP := homalgTable( R );[104X771[4X [104X772[4X if IsBound(RP!.PositionOfFirstNonZeroEntryPerRow) then[104X773[4X return RP!.PositionOfFirstNonZeroEntryPerRow( M );[104X774[4X elif IsBound(RP!.PositionOfFirstNonZeroEntryPerColumn) then[104X775[4X return PositionOfFirstNonZeroEntryPerColumn( Involution( M ) );[104X776[4X fi;[104X777[4X [104X778[4X #=====# the fallback method #=====#[104X779[4X [104X780[4X entries := EntriesOfHomalgMatrix( M );[104X781[4X [104X782[4X r := NrRows( M );[104X783[4X c := NrColumns( M );[104X784[4X [104X785[4X pos := ListWithIdenticalEntries( r, 0 );[104X786[4X [104X787[4X for i in [ 1 .. r ] do[104X788[4X k := (i - 1) * c;[104X789[4X for j in [ 1 .. c ] do[104X790[4X if not IsZero( entries[k + j] ) then[104X791[4X pos[i] := j;[104X792[4X break;[104X793[4X fi;[104X794[4X od;[104X795[4X od;[104X796[4X [104X797[4X return pos;[104X798[4X [104X799[4Xend );[104X800[4X[32X[104X801802[1XB.2-10 PositionOfFirstNonZeroEntryPerColumn[101X803804[29X[2XPositionOfFirstNonZeroEntryPerColumn[102X( [3XM[103X, [3Xposlist[103X ) [32X function805[6XReturns:[106X [33X[0;10Ya list of nonnegative integers[133X806807[33X[0;0YLet [22XR :=[122X [10XHomalgRing[110X[22X( [3XM[103X )[122X and [22XRP :=[122X [10XhomalgTable[110X[22X( R )[122X. If the [10XhomalgTable[110X808component [22XRP[122X!.[10XPositionOfFirstNonZeroEntryPerColumn[110X is bound then the809standard method of the attribute [2XPositionOfFirstNonZeroEntryPerColumn[102X810([14X5.4-9[114X) shown below returns [22XRP[122X!.[10XPositionOfFirstNonZeroEntryPerColumn[110X[22X( [3XM[103X )[122X.[133X811812[4X[32X Code [32X[104X813[4XInstallMethod( PositionOfFirstNonZeroEntryPerColumn,[104X814[4X "for homalg matrices",[104X815[4X [ IsHomalgMatrix ],[104X816[4X [104X817[4X function( M )[104X818[4X local R, RP, pos, entries, r, c, j, i, k;[104X819[4X [104X820[4X R := HomalgRing( M );[104X821[4X [104X822[4X RP := homalgTable( R );[104X823[4X [104X824[4X if IsBound(RP!.PositionOfFirstNonZeroEntryPerColumn) then[104X825[4X return RP!.PositionOfFirstNonZeroEntryPerColumn( M );[104X826[4X elif IsBound(RP!.PositionOfFirstNonZeroEntryPerRow) then[104X827[4X return PositionOfFirstNonZeroEntryPerRow( Involution( M ) );[104X828[4X fi;[104X829[4X [104X830[4X #=====# the fallback method #=====#[104X831[4X [104X832[4X entries := EntriesOfHomalgMatrix( M );[104X833[4X [104X834[4X r := NrRows( M );[104X835[4X c := NrColumns( M );[104X836[4X [104X837[4X pos := ListWithIdenticalEntries( c, 0 );[104X838[4X [104X839[4X for j in [ 1 .. c ] do[104X840[4X for i in [ 1 .. r ] do[104X841[4X k := (i - 1) * c;[104X842[4X if not IsZero( entries[k + j] ) then[104X843[4X pos[j] := i;[104X844[4X break;[104X845[4X fi;[104X846[4X od;[104X847[4X od;[104X848[4X [104X849[4X return pos;[104X850[4X [104X851[4Xend );[104X852[4X[32X[104X853854855856