  
  [1XD The Matrix Tool Operations[0X
  
  The  functions  listed below are components of the [10XhomalgTable[0m object stored
  in  the  ring.  They are only indirectly accessible through standard methods
  that invoke them.
  
  
  [1XD.1 The Tool Operations [13Xwithout[1X a Fallback Method[0X
  
  There  are  matrix  methods  for  which [5Xhomalg[0m needs a [10XhomalgTable[0m entry for
  non-internal  rings,  as it cannot provide a suitable fallback. Below is the
  list of these [10XhomalgTable[0m entries.
  
  [1XD.1-1 ZeroMatrix[0m
  
  [2X> ZeroMatrix( [0X[3XC[0X[2X ) __________________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XZeroMatrix[0m  is  bound then the method [2XEval[0m ([14XE.4-1[0m) resets the
  filter [10XIsInitialMatrix[0m and returns RP!.[10XZeroMatrix[0m( [3XC[0m ).
  
  [1XD.1-2 IdentityMatrix[0m
  
  [2X> IdentityMatrix( [0X[3XC[0X[2X ) ______________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XIdentityMatrix[0m  is  bound then the method [2XEval[0m ([14XE.4-2[0m) resets
  the filter [10XIsInitialIdentityMatrix[0m and returns RP!.[10XIdentityMatrix[0m( [3XC[0m ).
  
  [1XD.1-3 ZeroMatrix[0m
  
  [2X> ZeroMatrix( [0X[3XC[0X[2X ) __________________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XZeroMatrix[0m  is  bound  then  the  method [2XEval[0m ([14XE.4-3[0m) returns
  RP!.[10XZeroMatrix[0m( [3XC[0m ).
  
  [1XD.1-4 IdentityMatrix[0m
  
  [2X> IdentityMatrix( [0X[3XC[0X[2X ) ______________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XIdentityMatrix[0m  is bound then the method [2XEval[0m ([14XE.4-4[0m) returns
  RP!.[10XIdentityMatrix[0m( [3XC[0m ).
  
  [1XD.1-5 Involution[0m
  
  [2X> Involution( [0X[3XM[0X[2X ) __________________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XInvolution[0m  is  bound  then  the  method [2XEval[0m ([14XE.4-5[0m) returns
  RP!.[10XInvolution[0m applied to the content of the attribute [10XEvalInvolution[0m( [3XC[0m ) =
  [3XM[0m.
  
  [1XD.1-6 CertainRows[0m
  
  [2X> CertainRows( [0X[3XM, plist[0X[2X ) __________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XCertainRows[0m  is  bound  then  the method [2XEval[0m ([14XE.4-6[0m) returns
  RP!.[10XCertainRows[0m applied to the content of the attribute [10XEvalCertainRows[0m( [3XC[0m )
  = [ [3XM[0m, [3Xplist[0m ].
  
  [1XD.1-7 CertainColumns[0m
  
  [2X> CertainColumns( [0X[3XM, plist[0X[2X ) _______________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XCertainColumns[0m  is bound then the method [2XEval[0m ([14XE.4-7[0m) returns
  RP!.[10XCertainColumns[0m    applied    to    the    content   of   the   attribute
  [10XEvalCertainColumns[0m( [3XC[0m ) = [ [3XM[0m, [3Xplist[0m ].
  
  [1XD.1-8 UnionOfRows[0m
  
  [2X> UnionOfRows( [0X[3XA, B[0X[2X ) ______________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XUnionOfRows[0m  is  bound  then  the method [2XEval[0m ([14XE.4-8[0m) returns
  RP!.[10XUnionOfRows[0m applied to the content of the attribute [10XEvalUnionOfRows[0m( [3XC[0m )
  = [ [3XA[0m, [3XB[0m ].
  
  [1XD.1-9 UnionOfColumns[0m
  
  [2X> UnionOfColumns( [0X[3XA, B[0X[2X ) ___________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XUnionOfColumns[0m  is bound then the method [2XEval[0m ([14XE.4-9[0m) returns
  RP!.[10XUnionOfColumns[0m    applied    to    the    content   of   the   attribute
  [10XEvalUnionOfColumns[0m( [3XC[0m ) = [ [3XA[0m, [3XB[0m ].
  
  [1XD.1-10 DiagMat[0m
  
  [2X> DiagMat( [0X[3Xe[0X[2X ) _____________________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XDiagMat[0m  is  bound  then  the  method  [2XEval[0m  ([14XE.4-10[0m) returns
  RP!.[10XDiagMat[0m applied to the content of the attribute [10XEvalDiagMat[0m( [3XC[0m ) = [3Xe[0m.
  
  [1XD.1-11 KroneckerMat[0m
  
  [2X> KroneckerMat( [0X[3XA, B[0X[2X ) _____________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XKroneckerMat[0m  is  bound then the method [2XEval[0m ([14XE.4-11[0m) returns
  RP!.[10XKroneckerMat[0m applied to the content of the attribute [10XEvalKroneckerMat[0m( [3XC[0m
  ) = [ [3XA[0m, [3XB[0m ].
  
  [1XD.1-12 MulMat[0m
  
  [2X> MulMat( [0X[3Xa, A[0X[2X ) ___________________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XMulMat[0m  is  bound  then  the  method  [2XEval[0m  ([14XE.4-12[0m)  returns
  RP!.[10XMulMat[0m  applied to the content of the attribute [10XEvalMulMat[0m( [3XC[0m ) = [ [3Xa[0m, [3XA[0m
  ].
  
  [1XD.1-13 AddMat[0m
  
  [2X> AddMat( [0X[3XA, B[0X[2X ) ___________________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XAddMat[0m  is  bound  then  the  method  [2XEval[0m  ([14XE.4-13[0m)  returns
  RP!.[10XAddMat[0m  applied to the content of the attribute [10XEvalAddMat[0m( [3XC[0m ) = [ [3XA[0m, [3XB[0m
  ].
  
  [1XD.1-14 SubMat[0m
  
  [2X> SubMat( [0X[3XA, B[0X[2X ) ___________________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XSubMat[0m  is  bound  then  the  method  [2XEval[0m  ([14XE.4-14[0m)  returns
  RP!.[10XSubMat[0m  applied to the content of the attribute [10XEvalSubMat[0m( [3XC[0m ) = [ [3XA[0m, [3XB[0m
  ].
  
  [1XD.1-15 Compose[0m
  
  [2X> Compose( [0X[3XA, B[0X[2X ) __________________________________________________[0Xfunction
  [6XReturns:[0X  the [10XEval[0m value of a [5Xhomalg[0m matrix [3XC[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XCompose[0m  is  bound  then  the  method  [2XEval[0m  ([14XE.4-15[0m) returns
  RP!.[10XCompose[0m  applied to the content of the attribute [10XEvalCompose[0m( [3XC[0m ) = [ [3XA[0m,
  [3XB[0m ].
  
  [1XD.1-16 IsZeroMatrix[0m
  
  [2X> IsZeroMatrix( [0X[3XM[0X[2X ) ________________________________________________[0Xfunction
  [6XReturns:[0X  [10Xtrue[0m or [10Xfalse[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XM[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XIsZeroMatrix[0m  is  bound  then  the  standard  method  for the
  property [2XIsZero[0m ([14X6.3-1[0m) shown below returns RP!.[10XIsZeroMatrix[0m( [3XM[0m ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( IsZero,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix ],[0X
    [4X        [0X
    [4X  function( M )[0X
    [4X    local R, RP;[0X
    [4X    [0X
    [4X    R := HomalgRing( M );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if IsBound(RP!.IsZeroMatrix) then[0X
    [4X        ## CAUTION: the external system must be able[0X
    [4X        ## to check zero modulo possible ring relations![0X
    [4X        [0X
    [4X        return RP!.IsZeroMatrix( M ); ## with this, \= can fall back to IsZero[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    #=====# the fallback method #=====#[0X
    [4X    [0X
    [4X    ## from the GAP4 documentation: ?Zero[0X
    [4X    ## `ZeroSameMutability( <obj> )' is equivalent to `0 * <obj>'.[0X
    [4X    [0X
    [4X    return M = 0 * M; ## hence, by default, IsZero falls back to \= (see below)[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
  [1XD.1-17 NrRows[0m
  
  [2X> NrRows( [0X[3XC[0X[2X ) ______________________________________________________[0Xfunction
  [6XReturns:[0X  a nonnegative integer
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XNrRows[0m  is  bound  then the standard method for the attribute
  [2XNrRows[0m ([14X6.4-1[0m) shown below returns RP!.[10XNrRows[0m( [3XC[0m ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( NrRows,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix ],[0X
    [4X        [0X
    [4X  function( C )[0X
    [4X    local R, RP;[0X
    [4X    [0X
    [4X    R := HomalgRing( C );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if IsBound(RP!.NrRows) then[0X
    [4X        return RP!.NrRows( C );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    if not IsHomalgInternalMatrixRep( C ) then[0X
    [4X        Error( "could not find a procedure called NrRows in the ",[0X
    [4X               "homalgTable to apply to a non-internal matrix\n" );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    #=====# can only work for homalg internal matrices #=====#[0X
    [4X    [0X
    [4X    return Length( Eval( C )!.matrix );[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
  [1XD.1-18 NrColumns[0m
  
  [2X> NrColumns( [0X[3XC[0X[2X ) ___________________________________________________[0Xfunction
  [6XReturns:[0X  a nonnegative integer
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XNrColumns[0m is bound then the standard method for the attribute
  [2XNrColumns[0m ([14X6.4-2[0m) shown below returns RP!.[10XNrColumns[0m( [3XC[0m ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( NrColumns,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix ],[0X
    [4X        [0X
    [4X  function( C )[0X
    [4X    local R, RP;[0X
    [4X    [0X
    [4X    R := HomalgRing( C );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if IsBound(RP!.NrColumns) then[0X
    [4X        return RP!.NrColumns( C );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    if not IsHomalgInternalMatrixRep( C ) then[0X
    [4X        Error( "could not find a procedure called NrColumns in the ",[0X
    [4X               "homalgTable to apply to a non-internal matrix\n" );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    #=====# can only work for homalg internal matrices #=====#[0X
    [4X    [0X
    [4X    return Length( Eval( C )!.matrix[ 1 ] );[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
  [1XD.1-19 Determinant[0m
  
  [2X> Determinant( [0X[3XC[0X[2X ) _________________________________________________[0Xfunction
  [6XReturns:[0X  a ring element
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XDeterminant[0m  is  bound  then  the  standard  method  for  the
  attribute [2XDeterminantMat[0m ([14X6.4-3[0m) shown below returns RP!.[10XDeterminant[0m( [3XC[0m ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( DeterminantMat,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix ],[0X
    [4X        [0X
    [4X  function( C )[0X
    [4X    local R, RP;[0X
    [4X    [0X
    [4X    R := HomalgRing( C );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if NrRows( C ) <> NrColumns( C ) then[0X
    [4X        Error( "the matrix is not quadratic\n" );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    if IsBound(RP!.Determinant) then[0X
    [4X        return RingElementConstructor( R )( RP!.Determinant( C ), R );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    if not IsHomalgInternalMatrixRep( C ) then[0X
    [4X        Error( "could not find a procedure called Determinant in the ",[0X
    [4X               "homalgTable to apply to a non-internal matrix\n" );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    #=====# can only work for homalg internal matrices #=====#[0X
    [4X    [0X
    [4X    return Determinant( Eval( C )!.matrix );[0X
    [4X    [0X
    [4Xend );[0X
    [4X[0X
    [4X[0X
    [4XInstallMethod( Determinant,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix ],[0X
    [4X        [0X
    [4X  function( C )[0X
    [4X    [0X
    [4X    return DeterminantMat( C );[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
  
  [1XD.2 The Tool Operations with a Fallback Method[0X
  
  These are the methods for which it is recommended for performance reasons to
  have  a  [10XhomalgTable[0m  entry  for  non-internal rings. [5Xhomalg[0m only provides a
  generic fallback method.
  
  [1XD.2-1 AreEqualMatrices[0m
  
  [2X> AreEqualMatrices( [0X[3XM1, M2[0X[2X ) _______________________________________[0Xfunction
  [6XReturns:[0X  [10Xtrue[0m or [10Xfalse[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XM1[0m ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XAreEqualMatrices[0m  is  bound  then the standard method for the
  operation [2X\=[0m ([14X6.5-13[0m) shown below returns RP!.[10XAreEqualMatrices[0m( [3XM1[0m, [3XM2[0m ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( \=,[0X
    [4X        "for homalg comparable matrices",[0X
    [4X        [ IsHomalgMatrix, IsHomalgMatrix ],[0X
    [4X        [0X
    [4X  function( M1, M2 )[0X
    [4X    local R, RP;[0X
    [4X    [0X
    [4X    R := HomalgRing( M1 );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if IsBound(RP!.AreEqualMatrices) then[0X
    [4X        ## CAUTION: the external system must be able to check equality[0X
    [4X        ## modulo possible ring relations (known to the external system)![0X
    [4X        return RP!.AreEqualMatrices( M1, M2 );[0X
    [4X    elif IsBound(RP!.Equal) then[0X
    [4X        ## CAUTION: the external system must be able to check equality[0X
    [4X        ## modulo possible ring relations (known to the external system)![0X
    [4X        return RP!.Equal( M1, M2 );[0X
    [4X    elif IsBound(RP!.IsZeroMatrix) then   ## ensuring this avoids infinite loops[0X
    [4X        return IsZero( M1 - M2 );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    TryNextMethod( );[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
  [1XD.2-2 IsIdentityMatrix[0m
  
  [2X> IsIdentityMatrix( [0X[3XM[0X[2X ) ____________________________________________[0Xfunction
  [6XReturns:[0X  [10Xtrue[0m or [10Xfalse[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XM[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XIsIdentityMatrix[0m  is  bound  then the standard method for the
  property  [2XIsIdentityMatrix[0m ([14X6.3-2[0m) shown below returns RP!.[10XIsIdentityMatrix[0m(
  [3XM[0m ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( IsIdentityMatrix,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix ],[0X
    [4X        [0X
    [4X  function( M )[0X
    [4X    local R, RP;[0X
    [4X    [0X
    [4X    R := HomalgRing( M );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if IsBound(RP!.IsIdentityMatrix) then[0X
    [4X        return RP!.IsIdentityMatrix( M );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    #=====# the fallback method #=====#[0X
    [4X    [0X
    [4X    return M = HomalgIdentityMatrix( NrRows( M ), HomalgRing( M ) );[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
  [1XD.2-3 IsDiagonalMatrix[0m
  
  [2X> IsDiagonalMatrix( [0X[3XM[0X[2X ) ____________________________________________[0Xfunction
  [6XReturns:[0X  [10Xtrue[0m or [10Xfalse[0m
  
  Let  R  :=  [10XHomalgRing[0m(  [3XM[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XIsDiagonalMatrix[0m  is  bound  then the standard method for the
  property [2XIsDiagonalMatrix[0m ([14X6.3-12[0m) shown below returns RP!.[10XIsDiagonalMatrix[0m(
  [3XM[0m ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( IsDiagonalMatrix,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix ],[0X
    [4X        [0X
    [4X  function( M )[0X
    [4X    local R, RP, diag;[0X
    [4X    [0X
    [4X    R := HomalgRing( M );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if IsBound(RP!.IsDiagonalMatrix) then[0X
    [4X        return RP!.IsDiagonalMatrix( M );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    #=====# the fallback method #=====#[0X
    [4X    [0X
    [4X    diag := DiagonalEntries( M );[0X
    [4X    [0X
    [4X    return M = HomalgDiagonalMatrix( diag, NrRows( M ), NrColumns( M ), R );[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
  [1XD.2-4 ZeroRows[0m
  
  [2X> ZeroRows( [0X[3XC[0X[2X ) ____________________________________________________[0Xfunction
  [6XReturns:[0X  a (possibly empty) list of positive integers
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XZeroRows[0m  is  bound then the standard method of the attribute
  [2XZeroRows[0m ([14X6.4-4[0m) shown below returns RP!.[10XZeroRows[0m( [3XC[0m ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( ZeroRows,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix ],[0X
    [4X        [0X
    [4X  function( C )[0X
    [4X    local R, RP, z;[0X
    [4X    [0X
    [4X    R := HomalgRing( C );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if IsBound(RP!.ZeroRows) then[0X
    [4X        return RP!.ZeroRows( C );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    #=====# the fallback method #=====#[0X
    [4X    [0X
    [4X    z := HomalgZeroMatrix( 1, NrColumns( C ), R );[0X
    [4X    [0X
    [4X    return Filtered( [ 1 .. NrRows( C ) ], a -> CertainRows( C, [ a ] ) = z );[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
  [1XD.2-5 ZeroColumns[0m
  
  [2X> ZeroColumns( [0X[3XC[0X[2X ) _________________________________________________[0Xfunction
  [6XReturns:[0X  a (possibly empty) list of positive integers
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component RP!.[10XZeroColumns[0m is bound then the standard method of the attribute
  [2XZeroColumns[0m ([14X6.4-5[0m) shown below returns RP!.[10XZeroColumns[0m( [3XC[0m ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( ZeroColumns,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix ],[0X
    [4X        [0X
    [4X  function( C )[0X
    [4X    local R, RP, z;[0X
    [4X    [0X
    [4X    R := HomalgRing( C );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if IsBound(RP!.ZeroColumns) then[0X
    [4X        return RP!.ZeroColumns( C );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    #=====# the fallback method #=====#[0X
    [4X    [0X
    [4X    z := HomalgZeroMatrix( NrRows( C ), 1, R );[0X
    [4X    [0X
    [4X    return Filtered( [ 1 .. NrColumns( C ) ], a -> CertainColumns( C, [ a ] ) = z );[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
  [1XD.2-6 GetColumnIndependentUnitPositions[0m
  
  [2X> GetColumnIndependentUnitPositions( [0X[3XM, poslist[0X[2X ) __________________[0Xfunction
  [6XReturns:[0X  a (possibly empty) list of pairs of positive integers
  
  Let  R  :=  [10XHomalgRing[0m(  [3XM[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XGetColumnIndependentUnitPositions[0m  is bound then the standard
  method  of  the operation [2XGetColumnIndependentUnitPositions[0m ([14X6.5-14[0m) returns
  RP!.[10XGetColumnIndependentUnitPositions[0m( [3XM[0m, [3Xposlist[0m ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( GetColumnIndependentUnitPositions,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix, IsHomogeneousList ],[0X
    [4X        [0X
    [4X  function( M, poslist )[0X
    [4X    local R, RP, rest, pos, i, j, k;[0X
    [4X    [0X
    [4X    R := HomalgRing( M );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if IsBound(RP!.GetColumnIndependentUnitPositions) then[0X
    [4X        pos := RP!.GetColumnIndependentUnitPositions( M, poslist );[0X
    [4X        if pos <> [ ] then[0X
    [4X            SetIsZero( M, false );[0X
    [4X        fi;[0X
    [4X        return pos;[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    #=====# the fallback method #=====#[0X
    [4X    [0X
    [4X    rest := [ 1 .. NrColumns( M ) ];[0X
    [4X    [0X
    [4X    pos := [ ];[0X
    [4X    [0X
    [4X    for i in [ 1 .. NrRows( M ) ] do[0X
    [4X        for k in Reversed( rest ) do[0X
    [4X            if not [ i, k ] in poslist and[0X
    [4X               IsUnit( R, GetEntryOfHomalgMatrix( M, i, k ) ) then[0X
    [4X                Add( pos, [ i, k ] );[0X
    [4X                rest := Filtered( rest,[0X
    [4X                                a -> IsZero( GetEntryOfHomalgMatrix( M, i, a ) ) );[0X
    [4X                break;[0X
    [4X            fi;[0X
    [4X        od;[0X
    [4X    od;[0X
    [4X    [0X
    [4X    if pos <> [ ] then[0X
    [4X        SetIsZero( M, false );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    return pos;[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
  [1XD.2-7 GetRowIndependentUnitPositions[0m
  
  [2X> GetRowIndependentUnitPositions( [0X[3XM, poslist[0X[2X ) _____________________[0Xfunction
  [6XReturns:[0X  a (possibly empty) list of pairs of positive integers
  
  Let  R  :=  [10XHomalgRing[0m(  [3XM[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XGetRowIndependentUnitPositions[0m  is  bound  then  the standard
  method  of  the  operation  [2XGetRowIndependentUnitPositions[0m  ([14X6.5-15[0m) returns
  RP!.[10XGetRowIndependentUnitPositions[0m( [3XM[0m, [3Xposlist[0m ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( GetRowIndependentUnitPositions,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix, IsHomogeneousList ],[0X
    [4X        [0X
    [4X  function( M, poslist )[0X
    [4X    local R, RP, rest, pos, j, i, k;[0X
    [4X    [0X
    [4X    R := HomalgRing( M );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if IsBound(RP!.GetRowIndependentUnitPositions) then[0X
    [4X        pos := RP!.GetRowIndependentUnitPositions( M, poslist );[0X
    [4X        if pos <> [ ] then[0X
    [4X            SetIsZero( M, false );[0X
    [4X        fi;[0X
    [4X        return pos;[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    #=====# the fallback method #=====#[0X
    [4X    [0X
    [4X    rest := [ 1 .. NrRows( M ) ];[0X
    [4X    [0X
    [4X    pos := [ ];[0X
    [4X    [0X
    [4X    for j in [ 1 .. NrColumns( M ) ] do[0X
    [4X        for k in Reversed( rest ) do[0X
    [4X            if not [ j, k ] in poslist and[0X
    [4X               IsUnit( R, GetEntryOfHomalgMatrix( M, k, j ) ) then[0X
    [4X                Add( pos, [ j, k ] );[0X
    [4X                rest := Filtered( rest,[0X
    [4X                                a -> IsZero( GetEntryOfHomalgMatrix( M, a, j ) ) );[0X
    [4X                break;[0X
    [4X            fi;[0X
    [4X        od;[0X
    [4X    od;[0X
    [4X    [0X
    [4X    if pos <> [ ] then[0X
    [4X        SetIsZero( M, false );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    return pos;[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
  [1XD.2-8 GetUnitPosition[0m
  
  [2X> GetUnitPosition( [0X[3XM, poslist[0X[2X ) ____________________________________[0Xfunction
  [6XReturns:[0X  a (possibly empty) list of pairs of positive integers
  
  Let  R  :=  [10XHomalgRing[0m(  [3XM[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XGetUnitPosition[0m  is  bound  then  the  standard method of the
  operation  [2XGetUnitPosition[0m  ([14X6.5-16[0m) returns RP!.[10XGetUnitPosition[0m( [3XM[0m, [3Xposlist[0m
  ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( GetUnitPosition,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix, IsHomogeneousList ],[0X
    [4X        [0X
    [4X  function( M, poslist )[0X
    [4X    local R, RP, pos, m, n, i, j;[0X
    [4X    [0X
    [4X    R := HomalgRing( M );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if IsBound(RP!.GetUnitPosition) then[0X
    [4X        pos := RP!.GetUnitPosition( M, poslist );[0X
    [4X        if IsList( pos ) and IsPosInt( pos[1] ) and IsPosInt( pos[2] ) then[0X
    [4X            SetIsZero( M, false );[0X
    [4X        fi;[0X
    [4X        return pos;[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    #=====# the fallback method #=====#[0X
    [4X    [0X
    [4X    m := NrRows( M );[0X
    [4X    n := NrColumns( M );[0X
    [4X    [0X
    [4X    for i in [ 1 .. m ] do[0X
    [4X        for j in [ 1 .. n ] do[0X
    [4X            if not [ i, j ] in poslist and not j in poslist and[0X
    [4X               IsUnit( R, GetEntryOfHomalgMatrix( M, i, j ) ) then[0X
    [4X                SetIsZero( M, false );[0X
    [4X                return [ i, j ];[0X
    [4X            fi;[0X
    [4X        od;[0X
    [4X    od;[0X
    [4X    [0X
    [4X    return fail;[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
  [1XD.2-9 DegreesOfEntries[0m
  
  [2X> DegreesOfEntries( [0X[3XC[0X[2X ) ____________________________________________[0Xfunction
  [6XReturns:[0X  a listlist of degrees/multi-degrees
  
  Let  R  :=  [10XHomalgRing[0m(  [3XC[0m  ) and RP := [10XhomalgTable[0m( R ). If the [10XhomalgTable[0m
  component  RP!.[10XDegreesOfEntries[0m  is  bound  then the standard method for the
  attribute      [2XDegreesOfEntries[0m     ([14X6.4-10[0m)     shown     below     returns
  RP!.[10XDegreesOfEntries[0m( [3XC[0m ).
  
  [4X-----------------------------  Code  -----------------------------[0X
    [4XInstallMethod( DegreesOfEntries,[0X
    [4X        "for homalg matrices",[0X
    [4X        [ IsHomalgMatrix ],[0X
    [4X        [0X
    [4X  function( C )[0X
    [4X    local R, RP, weights, e, c;[0X
    [4X    [0X
    [4X    if IsZero( C ) then[0X
    [4X        return ListWithIdenticalEntries( NrRows( C ),[0X
    [4X                       ListWithIdenticalEntries( NrColumns( C ), -1 ) );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    R := HomalgRing( C );[0X
    [4X    [0X
    [4X    RP := homalgTable( R );[0X
    [4X    [0X
    [4X    if Set( WeightsOfIndeterminates( R ) ) <> [ 1 ] then[0X
    [4X        [0X
    [4X        weights := WeightsOfIndeterminates( R );[0X
    [4X        [0X
    [4X        if IsList( weights[1] ) then[0X
    [4X            if IsBound(RP!.MultiWeightedDegreesOfEntries) then[0X
    [4X                return RP!.MultiWeightedDegreesOfEntries( C, weights );[0X
    [4X            fi;[0X
    [4X        elif IsBound(RP!.WeightedDegreesOfEntries) then[0X
    [4X            return RP!.WeightedDegreesOfEntries( C, weights );[0X
    [4X        fi;[0X
    [4X        [0X
    [4X    elif IsBound(RP!.DegreesOfEntries) then[0X
    [4X        return RP!.DegreesOfEntries( C );[0X
    [4X    fi;[0X
    [4X    [0X
    [4X    #=====# the fallback method #=====#[0X
    [4X    [0X
    [4X    e := EntriesOfHomalgMatrix( C );[0X
    [4X    [0X
    [4X    e := List( e, DegreeMultivariatePolynomial );[0X
    [4X    [0X
    [4X    c := NrColumns( C );[0X
    [4X    [0X
    [4X    return List( [ 1 .. NrRows( C ) ], r -> e{[ ( r - 1 ) * c + 1 .. r * c ]} );[0X
    [4X    [0X
    [4Xend );[0X
  [4X------------------------------------------------------------------[0X
  
