The functions listed below are components of the homalgTable object stored in the ring. They are only indirectly accessible through standard methods that invoke them.
There are matrix methods for which homalg needs a homalgTable entry for non-internal rings, as it cannot provide a suitable fallback. Below is the list of these homalgTable entries.
‣ InitialMatrix( C ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.InitialMatrix is bound then the method Eval (C.4-1) resets the filter IsInitialMatrix and returns \(RP\)!.InitialMatrix\(( \textit{C} )\).
‣ InitialIdentityMatrix( C ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.InitialIdentityMatrix is bound then the method Eval (C.4-2) resets the filter IsInitialIdentityMatrix and returns \(RP\)!.InitialIdentityMatrix\(( \textit{C} )\).
‣ ZeroMatrix( C ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.ZeroMatrix is bound then the method Eval (C.4-3) returns \(RP\)!.ZeroMatrix\(( \textit{C} )\).
‣ IdentityMatrix( C ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.IdentityMatrix is bound then the method Eval (C.4-4) returns \(RP\)!.IdentityMatrix\(( \textit{C} )\).
‣ Involution( M ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.Involution is bound then the method Eval (C.4-7) returns \(RP\)!.Involution applied to the content of the attribute EvalInvolution\(( \textit{C} ) = \textit{M}\).
‣ TransposedMatrix( M ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.TransposedMatrix is bound then the method Eval (C.4-8) returns \(RP\)!.TransposedMatrix applied to the content of the attribute EvalTransposedMatrix\(( \textit{C} ) = \textit{M}\).
‣ CertainRows( M, plist ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.CertainRows is bound then the method Eval (C.4-10) returns \(RP\)!.CertainRows applied to the content of the attribute EvalCertainRows\(( \textit{C} ) = [ \textit{M}, \textit{plist} ]\).
‣ CertainColumns( M, plist ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.CertainColumns is bound then the method Eval (C.4-11) returns \(RP\)!.CertainColumns applied to the content of the attribute EvalCertainColumns\(( \textit{C} ) = [ \textit{M}, \textit{plist} ]\).
‣ UnionOfRows( L ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.UnionOfRows is bound then the method Eval (C.4-12) returns \(RP\)!.UnionOfRows applied to the content of the attribute EvalUnionOfRows\(( \textit{C} ) = \textit{L}\).
‣ UnionOfRowsPair( A, B ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.UnionOfRowsPair is bound and the homalgTable component \(RP\)!.UnionOfRows is not bound then the method Eval (C.4-12) returns \(RP\)!.UnionOfRowsPair applied recursively to a balanced binary tree created from the content of the attribute EvalUnionOfRows\(( \textit{C} )\).
‣ UnionOfColumns( L ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.UnionOfColumns is bound then the method Eval (C.4-13) returns \(RP\)!.UnionOfColumns applied to the content of the attribute EvalUnionOfColumns\(( \textit{C} ) = \textit{L}\).
‣ UnionOfColumnsPair( A, B ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.UnionOfColumnsPair is bound and the homalgTable component \(RP\)!.UnionOfColumns is not bound then the method Eval (C.4-13) returns \(RP\)!.UnionOfColumnsPair applied recursively to a balanced binary tree created from the content of the attribute EvalUnionOfRows\(( \textit{C} )\).
‣ DiagMat( e ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.DiagMat is bound then the method Eval (C.4-14) returns \(RP\)!.DiagMat applied to the content of the attribute EvalDiagMat\(( \textit{C} ) = \textit{e}\).
‣ KroneckerMat( A, B ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.KroneckerMat is bound then the method Eval (C.4-15) returns \(RP\)!.KroneckerMat applied to the content of the attribute EvalKroneckerMat\(( \textit{C} ) = [ \textit{A}, \textit{B} ]\).
‣ DualKroneckerMat( A, B ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.DualKroneckerMat is bound then the method Eval (C.4-16) returns \(RP\)!.DualKroneckerMat applied to the content of the attribute EvalDualKroneckerMat\(( \textit{C} ) = [ \textit{A}, \textit{B} ]\).
‣ MulMat( a, A ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.MulMat is bound then the method Eval (C.4-17) returns \(RP\)!.MulMat applied to the content of the attribute EvalMulMat\(( \textit{C} ) = [ \textit{a}, \textit{A} ]\).
‣ AddMat( A, B ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.AddMat is bound then the method Eval (C.4-18) returns \(RP\)!.AddMat applied to the content of the attribute EvalAddMat\(( \textit{C} ) = [ \textit{A}, \textit{B} ]\).
‣ SubMat( A, B ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.SubMat is bound then the method Eval (C.4-19) returns \(RP\)!.SubMat applied to the content of the attribute EvalSubMat\(( \textit{C} ) = [ \textit{A}, \textit{B} ]\).
‣ Compose( A, B ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.Compose is bound then the method Eval (C.4-20) returns \(RP\)!.Compose applied to the content of the attribute EvalCompose\(( \textit{C} ) = [ \textit{A}, \textit{B} ]\).
‣ IsZeroMatrix( M ) | ( function ) |
Returns: true or false
Let \(R :=\) HomalgRing\(( \textit{M} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.IsZeroMatrix is bound then the standard method for the property IsZero (5.3-1) shown below returns \(RP\)!.IsZeroMatrix\(( \textit{M} )\).
InstallMethod( IsZero,
"for homalg matrices",
[ IsHomalgMatrix ],
function( M )
local R, RP;
R := HomalgRing( M );
RP := homalgTable( R );
if IsBound(RP!.IsZeroMatrix) then
## CAUTION: the external system must be able
## to check zero modulo possible ring relations!
return RP!.IsZeroMatrix( M ); ## with this, \= can fall back to IsZero
fi;
#=====# the fallback method #=====#
## from the GAP4 documentation: ?Zero
## `ZeroSameMutability( <obj> )' is equivalent to `0 * <obj>'.
return M = 0 * M; ## hence, by default, IsZero falls back to \= (see below)
end );
‣ NrRows( C ) | ( function ) |
Returns: a nonnegative integer
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.NrRows is bound then the standard method for the attribute NrRows (5.4-1) shown below returns \(RP\)!.NrRows\(( \textit{C} )\).
InstallMethod( NrRows,
"for homalg matrices",
[ IsHomalgMatrix ],
function( C )
local R, RP;
R := HomalgRing( C );
RP := homalgTable( R );
if IsBound(RP!.NrRows) then
return RP!.NrRows( C );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called NrRows ",
"in the homalgTable of the non-internal ring\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return Length( Eval( C )!.matrix );
end );
‣ NrColumns( C ) | ( function ) |
Returns: a nonnegative integer
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.NrColumns is bound then the standard method for the attribute NrColumns (5.4-2) shown below returns \(RP\)!.NrColumns\(( \textit{C} )\).
InstallMethod( NrColumns,
"for homalg matrices",
[ IsHomalgMatrix ],
function( C )
local R, RP;
R := HomalgRing( C );
RP := homalgTable( R );
if IsBound(RP!.NrColumns) then
return RP!.NrColumns( C );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called NrColumns ",
"in the homalgTable of the non-internal ring\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return Length( Eval( C )!.matrix[ 1 ] );
end );
‣ Determinant( C ) | ( function ) |
Returns: a ring element
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.Determinant is bound then the standard method for the attribute DeterminantMat (5.4-3) shown below returns \(RP\)!.Determinant\(( \textit{C} )\).
InstallMethod( DeterminantMat,
"for homalg matrices",
[ IsHomalgMatrix ],
function( C )
local R, RP;
R := HomalgRing( C );
RP := homalgTable( R );
if NrRows( C ) <> NrColumns( C ) then
Error( "the matrix is not a square matrix\n" );
fi;
if IsEmptyMatrix( C ) then
return One( R );
elif IsZero( C ) then
return Zero( R );
fi;
if IsBound(RP!.Determinant) then
return RingElementConstructor( R )( RP!.Determinant( C ), R );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called Determinant ",
"in the homalgTable of the non-internal ring\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return Determinant( Eval( C )!.matrix );
end );
InstallMethod( Determinant,
"for homalg matrices",
[ IsHomalgMatrix ],
function( C )
return DeterminantMat( C );
end );
‣ CoefficientsWithGivenMonomials( M, monomials ) | ( function ) |
Returns: the Eval value of a homalg matrix C
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.CoefficientsWithGivenMonomials is bound then the method Eval (C.4-21) returns \(RP\)!.CoefficientsWithGivenMonomials applied to the content of the attribute EvalCoefficientsWithGivenMonomials\(( \textit{C} ) = [ \textit{M}, \textit{monomials} ]\).
These are the methods for which it is recommended for performance reasons to have a homalgTable entry for non-internal rings. homalg only provides a generic fallback method.
‣ AreEqualMatrices( M1, M2 ) | ( function ) |
Returns: true or false
Let \(R :=\) HomalgRing\(( \textit{M1} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.AreEqualMatrices is bound then the standard method for the operation \= (5.5-23) shown below returns \(RP\)!.AreEqualMatrices\(( \textit{M1}, \textit{M2} )\).
InstallMethod( \=,
"for homalg comparable matrices",
[ IsHomalgMatrix, IsHomalgMatrix ],
function( M1, M2 )
local R, RP, are_equal;
## do not touch mutable matrices
if not ( IsMutable( M1 ) or IsMutable( M2 ) ) then
if IsBound( M1!.AreEqual ) then
are_equal := _ElmWPObj_ForHomalg( M1!.AreEqual, M2, fail );
if are_equal <> fail then
return are_equal;
fi;
else
M1!.AreEqual :=
ContainerForWeakPointers(
TheTypeContainerForWeakPointersOnComputedValues,
[ "operation", "AreEqual" ] );
fi;
if IsBound( M2!.AreEqual ) then
are_equal := _ElmWPObj_ForHomalg( M2!.AreEqual, M1, fail );
if are_equal <> fail then
return are_equal;
fi;
fi;
## do not store things symmetrically below to ``save'' memory
fi;
R := HomalgRing( M1 );
RP := homalgTable( R );
if IsBound(RP!.AreEqualMatrices) then
## CAUTION: the external system must be able to check equality
## modulo possible ring relations (known to the external system)!
are_equal := RP!.AreEqualMatrices( M1, M2 );
elif IsBound(RP!.Equal) then
## CAUTION: the external system must be able to check equality
## modulo possible ring relations (known to the external system)!
are_equal := RP!.Equal( M1, M2 );
elif IsBound(RP!.IsZeroMatrix) then ## ensuring this avoids infinite loops
are_equal := IsZero( M1 - M2 );
fi;
if IsBound( are_equal ) then
## do not touch mutable matrices
if not ( IsMutable( M1 ) or IsMutable( M2 ) ) then
if are_equal then
MatchPropertiesAndAttributes( M1, M2,
LIMAT.intrinsic_properties,
LIMAT.intrinsic_attributes,
LIMAT.intrinsic_components,
LIMAT.intrinsic_attributes_do_not_check_their_equality
);
fi;
## do not store things symmetrically to ``save'' memory
_AddTwoElmWPObj_ForHomalg( M1!.AreEqual, M2, are_equal );
fi;
return are_equal;
fi;
TryNextMethod( );
end );
‣ IsIdentityMatrix( M ) | ( function ) |
Returns: true or false
Let \(R :=\) HomalgRing\(( \textit{M} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.IsIdentityMatrix is bound then the standard method for the property IsOne (5.3-2) shown below returns \(RP\)!.IsIdentityMatrix\(( \textit{M} )\).
InstallMethod( IsOne,
"for homalg matrices",
[ IsHomalgMatrix ],
function( M )
local R, RP;
if NrRows( M ) <> NrColumns( M ) then
return false;
fi;
R := HomalgRing( M );
RP := homalgTable( R );
if IsBound(RP!.IsIdentityMatrix) then
return RP!.IsIdentityMatrix( M );
fi;
#=====# the fallback method #=====#
return M = HomalgIdentityMatrix( NrRows( M ), HomalgRing( M ) );
end );
‣ IsDiagonalMatrix( M ) | ( function ) |
Returns: true or false
Let \(R :=\) HomalgRing\(( \textit{M} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.IsDiagonalMatrix is bound then the standard method for the property IsDiagonalMatrix (5.3-13) shown below returns \(RP\)!.IsDiagonalMatrix\(( \textit{M} )\).
InstallMethod( IsDiagonalMatrix,
"for homalg matrices",
[ IsHomalgMatrix ],
function( M )
local R, RP, diag;
R := HomalgRing( M );
RP := homalgTable( R );
if IsBound(RP!.IsDiagonalMatrix) then
return RP!.IsDiagonalMatrix( M );
fi;
#=====# the fallback method #=====#
diag := DiagonalEntries( M );
return M = HomalgDiagonalMatrix( diag, NrRows( M ), NrColumns( M ), R );
end );
‣ ZeroRows( C ) | ( function ) |
Returns: a (possibly empty) list of positive integers
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.ZeroRows is bound then the standard method of the attribute ZeroRows (5.4-4) shown below returns \(RP\)!.ZeroRows\(( \textit{C} )\).
InstallMethod( ZeroRows,
"for homalg matrices",
[ IsHomalgMatrix ],
function( C )
local R, RP, z;
R := HomalgRing( C );
RP := homalgTable( R );
if IsBound(RP!.ZeroRows) then
return RP!.ZeroRows( C );
fi;
#=====# the fallback method #=====#
z := HomalgZeroMatrix( 1, NrColumns( C ), R );
return Filtered( [ 1 .. NrRows( C ) ], a -> CertainRows( C, [ a ] ) = z );
end );
‣ ZeroColumns( C ) | ( function ) |
Returns: a (possibly empty) list of positive integers
Let \(R :=\) HomalgRing\(( \textit{C} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.ZeroColumns is bound then the standard method of the attribute ZeroColumns (5.4-5) shown below returns \(RP\)!.ZeroColumns\(( \textit{C} )\).
InstallMethod( ZeroColumns,
"for homalg matrices",
[ IsHomalgMatrix ],
function( C )
local R, RP, z;
R := HomalgRing( C );
RP := homalgTable( R );
if IsBound(RP!.ZeroColumns) then
return RP!.ZeroColumns( C );
fi;
#=====# the fallback method #=====#
z := HomalgZeroMatrix( NrRows( C ), 1, R );
return Filtered( [ 1 .. NrColumns( C ) ], a -> CertainColumns( C, [ a ] ) = z );
end );
‣ GetColumnIndependentUnitPositions( M, poslist ) | ( function ) |
Returns: a (possibly empty) list of pairs of positive integers
Let \(R :=\) HomalgRing\(( \textit{M} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.GetColumnIndependentUnitPositions is bound then the standard method of the operation GetColumnIndependentUnitPositions (5.5-24) shown below returns \(RP\)!.GetColumnIndependentUnitPositions\(( \textit{M}, \textit{poslist} )\).
InstallMethod( GetColumnIndependentUnitPositions,
"for homalg matrices",
[ IsHomalgMatrix, IsHomogeneousList ],
function( M, poslist )
local cache, R, RP, rest, pos, i, j, k;
if IsBound( M!.GetColumnIndependentUnitPositions ) then
cache := M!.GetColumnIndependentUnitPositions;
if IsBound( cache.(String( poslist )) ) then
return cache.(String( poslist ));
fi;
else
cache := rec( );
M!.GetColumnIndependentUnitPositions := cache;
fi;
R := HomalgRing( M );
RP := homalgTable( R );
if IsBound(RP!.GetColumnIndependentUnitPositions) then
pos := RP!.GetColumnIndependentUnitPositions( M, poslist );
if pos <> [ ] then
SetIsZero( M, false );
fi;
cache.(String( poslist )) := pos;
return pos;
fi;
#=====# the fallback method #=====#
rest := [ 1 .. NrColumns( M ) ];
pos := [ ];
for i in [ 1 .. NrRows( M ) ] do
for k in Reversed( rest ) do
if not [ i, k ] in poslist and
IsUnit( R, M[ i, k ] ) then
Add( pos, [ i, k ] );
rest := Filtered( rest,
a -> IsZero( M[ i, a ] ) );
break;
fi;
od;
od;
if pos <> [ ] then
SetIsZero( M, false );
fi;
cache.(String( poslist )) := pos;
return pos;
end );
‣ GetRowIndependentUnitPositions( M, poslist ) | ( function ) |
Returns: a (possibly empty) list of pairs of positive integers
Let \(R :=\) HomalgRing\(( \textit{M} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.GetRowIndependentUnitPositions is bound then the standard method of the operation GetRowIndependentUnitPositions (5.5-25) shown below returns \(RP\)!.GetRowIndependentUnitPositions\(( \textit{M}, \textit{poslist} )\).
InstallMethod( GetRowIndependentUnitPositions,
"for homalg matrices",
[ IsHomalgMatrix, IsHomogeneousList ],
function( M, poslist )
local cache, R, RP, rest, pos, j, i, k;
if IsBound( M!.GetRowIndependentUnitPositions ) then
cache := M!.GetRowIndependentUnitPositions;
if IsBound( cache.(String( poslist )) ) then
return cache.(String( poslist ));
fi;
else
cache := rec( );
M!.GetRowIndependentUnitPositions := cache;
fi;
R := HomalgRing( M );
RP := homalgTable( R );
if IsBound(RP!.GetRowIndependentUnitPositions) then
pos := RP!.GetRowIndependentUnitPositions( M, poslist );
if pos <> [ ] then
SetIsZero( M, false );
fi;
cache.( String( poslist ) ) := pos;
return pos;
fi;
#=====# the fallback method #=====#
rest := [ 1 .. NrRows( M ) ];
pos := [ ];
for j in [ 1 .. NrColumns( M ) ] do
for k in Reversed( rest ) do
if not [ j, k ] in poslist and
IsUnit( R, M[ k, j ] ) then
Add( pos, [ j, k ] );
rest := Filtered( rest,
a -> IsZero( M[ a, j ] ) );
break;
fi;
od;
od;
if pos <> [ ] then
SetIsZero( M, false );
fi;
cache.( String( poslist ) ) := pos;
return pos;
end );
‣ GetUnitPosition( M, poslist ) | ( function ) |
Returns: a (possibly empty) list of pairs of positive integers
Let \(R :=\) HomalgRing\(( \textit{M} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.GetUnitPosition is bound then the standard method of the operation GetUnitPosition (5.5-26) shown below returns \(RP\)!.GetUnitPosition\(( \textit{M}, \textit{poslist} )\).
InstallMethod( GetUnitPosition,
"for homalg matrices",
[ IsHomalgMatrix, IsHomogeneousList ],
function( M, poslist )
local R, RP, pos, m, n, i, j;
R := HomalgRing( M );
RP := homalgTable( R );
if IsBound(RP!.GetUnitPosition) then
pos := RP!.GetUnitPosition( M, poslist );
if IsList( pos ) and IsPosInt( pos[1] ) and IsPosInt( pos[2] ) then
SetIsZero( M, false );
fi;
return pos;
fi;
#=====# the fallback method #=====#
m := NrRows( M );
n := NrColumns( M );
for i in [ 1 .. m ] do
for j in [ 1 .. n ] do
if not [ i, j ] in poslist and not j in poslist and
IsUnit( R, M[ i, j ] ) then
SetIsZero( M, false );
return [ i, j ];
fi;
od;
od;
return fail;
end );
‣ PositionOfFirstNonZeroEntryPerRow( M, poslist ) | ( function ) |
Returns: a list of nonnegative integers
Let \(R :=\) HomalgRing\(( \textit{M} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.PositionOfFirstNonZeroEntryPerRow is bound then the standard method of the attribute PositionOfFirstNonZeroEntryPerRow (5.4-8) shown below returns \(RP\)!.PositionOfFirstNonZeroEntryPerRow\(( \textit{M} )\).
InstallMethod( PositionOfFirstNonZeroEntryPerRow,
"for homalg matrices",
[ IsHomalgMatrix ],
function( M )
local R, RP, pos, entries, r, c, i, k, j;
R := HomalgRing( M );
RP := homalgTable( R );
if IsBound(RP!.PositionOfFirstNonZeroEntryPerRow) then
return RP!.PositionOfFirstNonZeroEntryPerRow( M );
elif IsBound(RP!.PositionOfFirstNonZeroEntryPerColumn) then
return PositionOfFirstNonZeroEntryPerColumn( Involution( M ) );
fi;
#=====# the fallback method #=====#
entries := EntriesOfHomalgMatrix( M );
r := NrRows( M );
c := NrColumns( M );
pos := ListWithIdenticalEntries( r, 0 );
for i in [ 1 .. r ] do
k := (i - 1) * c;
for j in [ 1 .. c ] do
if not IsZero( entries[k + j] ) then
pos[i] := j;
break;
fi;
od;
od;
return pos;
end );
‣ PositionOfFirstNonZeroEntryPerColumn( M, poslist ) | ( function ) |
Returns: a list of nonnegative integers
Let \(R :=\) HomalgRing\(( \textit{M} )\) and \(RP :=\) homalgTable\(( R )\). If the homalgTable component \(RP\)!.PositionOfFirstNonZeroEntryPerColumn is bound then the standard method of the attribute PositionOfFirstNonZeroEntryPerColumn (5.4-9) shown below returns \(RP\)!.PositionOfFirstNonZeroEntryPerColumn\(( \textit{M} )\).
InstallMethod( PositionOfFirstNonZeroEntryPerColumn,
"for homalg matrices",
[ IsHomalgMatrix ],
function( M )
local R, RP, pos, entries, r, c, j, i, k;
R := HomalgRing( M );
RP := homalgTable( R );
if IsBound(RP!.PositionOfFirstNonZeroEntryPerColumn) then
return RP!.PositionOfFirstNonZeroEntryPerColumn( M );
elif IsBound(RP!.PositionOfFirstNonZeroEntryPerRow) then
return PositionOfFirstNonZeroEntryPerRow( Involution( M ) );
fi;
#=====# the fallback method #=====#
entries := EntriesOfHomalgMatrix( M );
r := NrRows( M );
c := NrColumns( M );
pos := ListWithIdenticalEntries( c, 0 );
for j in [ 1 .. c ] do
for i in [ 1 .. r ] do
k := (i - 1) * c;
if not IsZero( entries[k + j] ) then
pos[j] := i;
break;
fi;
od;
od;
return pos;
end );
generated by GAPDoc2HTML