Most of the matrix tool operations listed in Appendix D.1 which return a new matrix are lazy evaluated. The value of a homalg matrix is stored in the attribute Eval. Below is the list of the installed methods for the attribute Eval.
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix A was created using HomalgInitialMatrix (6.2-1) then the filter IsInitialMatrix for A is set to true and the homalgTable function (--> ZeroMatrix (D.1-1)) will be used to set the attribute Eval and resets the filter IsInitialMatrix.
InstallMethod( Eval,
"for homalg matrices (IsInitialMatrix)",
[ IsHomalgMatrix and IsInitialMatrix and
HasNrRows and HasNrColumns ],
function( C )
local R, RP, z, zz;
R := HomalgRing( C );
RP := homalgTable( R );
if IsBound( RP!.ZeroMatrix ) then
ResetFilterObj( C, IsInitialMatrix );
return RP!.ZeroMatrix( C );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called ZeroMatrix in the ",
"homalgTable to evaluate a non-internal initial matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
z := Zero( HomalgRing( C ) );
ResetFilterObj( C, IsInitialMatrix );
zz := ListWithIdenticalEntries( NrColumns( C ), z );
return homalgInternalMatrixHull(
List( [ 1 .. NrRows( C ) ], i -> ShallowCopy( zz ) ) );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix A was created using HomalgInitialIdentityMatrix (6.2-2) then the filter IsInitialIdentityMatrix for A is set to true and the homalgTable function (--> IdentityMatrix (D.1-2)) will be used to set the attribute Eval and resets the filter IsInitialIdentityMatrix.
InstallMethod( Eval,
"for homalg matrices (IsInitialIdentityMatrix)",
[ IsHomalgMatrix and IsInitialIdentityMatrix and
HasNrRows and HasNrColumns ],
function( C )
local R, RP, o, z, zz, id;
R := HomalgRing( C );
RP := homalgTable( R );
if IsBound( RP!.IdentityMatrix ) then
ResetFilterObj( C, IsInitialIdentityMatrix );
return RP!.IdentityMatrix( C );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called IdentityMatrix in the ",
"homalgTable to evaluate a non-internal initial identity matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
z := Zero( HomalgRing( C ) );
o := One( HomalgRing( C ) );
ResetFilterObj( C, IsInitialIdentityMatrix );
zz := ListWithIdenticalEntries( NrColumns( C ), z );
id := List( [ 1 .. NrRows( C ) ],
function(i)
local z;
z := ShallowCopy( zz ); z[i] := o; return z;
end );
return homalgInternalMatrixHull( id );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix A was created using HomalgZeroMatrix (6.2-3) then the filter IsZeroMatrix for A is set to true and the homalgTable function (--> ZeroMatrix (D.1-3)) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (IsZero)",
[ IsHomalgMatrix and IsZero and HasNrRows and HasNrColumns ], 20,
function( C )
local R, RP, z;
R := HomalgRing( C );
RP := homalgTable( R );
if ( NrRows( C ) = 0 or NrColumns( C ) = 0 ) and
not ( IsBound( R!.SafeToEvaluateEmptyMatrices ) and
R!.SafeToEvaluateEmptyMatrices = true ) then
Info( InfoWarning, 1, "\033[01m\033[5;31;47m",
"an empty matrix is about to get evaluated!",
"\033[0m" );
fi;
if IsBound( RP!.ZeroMatrix ) then
return RP!.ZeroMatrix( C );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called ZeroMatrix in the ",
"homalgTable to evaluate a non-internal zero matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
z := Zero( HomalgRing( C ) );
## copying the rows saves memory;
## we assume that the entries are never modified!!!
return homalgInternalMatrixHull(
ListWithIdenticalEntries( NrRows( C ),
ListWithIdenticalEntries( NrColumns( C ), z ) ) );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix A was created using HomalgIdentityMatrix (6.2-4) then the filter IsIdentityMatrix for A is set to true and the homalgTable function (--> IdentityMatrix (D.1-4)) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (IsIdentityMatrix)",
[ IsHomalgMatrix and IsIdentityMatrix and HasNrRows and HasNrColumns ], 10,
function( C )
local R, RP, o, z, zz, id;
R := HomalgRing( C );
RP := homalgTable( R );
if IsBound( RP!.IdentityMatrix ) then
return RP!.IdentityMatrix( C );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called IdentityMatrix in the ",
"homalgTable to evaluate a non-internal identity matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
z := Zero( HomalgRing( C ) );
o := One( HomalgRing( C ) );
zz := ListWithIdenticalEntries( NrColumns( C ), z );
id := List( [ 1 .. NrRows( C ) ],
function(i)
local z;
z := ShallowCopy( zz ); z[i] := o; return z;
end );
return homalgInternalMatrixHull( id );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix was created using Involution (6.5-2) then the filter HasEvalInvolution for A is set to true and the homalgTable function Involution (D.1-5) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (HasEvalInvolution)",
[ IsHomalgMatrix and HasEvalInvolution ],
function( C )
local R, RP, M;
R := HomalgRing( C );
RP := homalgTable( R );
M := EvalInvolution( C );
if IsBound(RP!.Involution) then
return RP!.Involution( M );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called Involution in the ",
"homalgTable to apply to a non-internal matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return homalgInternalMatrixHull( TransposedMat( Eval( M )!.matrix ) );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix was created using CertainRows (6.5-3) then the filter HasEvalCertainRows for A is set to true and the homalgTable function CertainRows (D.1-6) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (HasEvalCertainRows)",
[ IsHomalgMatrix and HasEvalCertainRows ],
function( C )
local R, RP, e, M, plist;
R := HomalgRing( C );
RP := homalgTable( R );
e := EvalCertainRows( C );
M := e[1];
plist := e[2];
if IsBound(RP!.CertainRows) then
return RP!.CertainRows( M, plist );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called CertainRows in the ",
"homalgTable to apply to a non-internal matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return homalgInternalMatrixHull( Eval( M )!.matrix{ plist } );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix was created using CertainColumns (6.5-4) then the filter HasEvalCertainColumns for A is set to true and the homalgTable function CertainColumns (D.1-7) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (HasEvalCertainColumns)",
[ IsHomalgMatrix and HasEvalCertainColumns ],
function( C )
local R, RP, e, M, plist;
R := HomalgRing( C );
RP := homalgTable( R );
e := EvalCertainColumns( C );
M := e[1];
plist := e[2];
if IsBound(RP!.CertainColumns) then
return RP!.CertainColumns( M, plist );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called CertainColumns in the ",
"homalgTable to apply to a non-internal matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return homalgInternalMatrixHull(
Eval( M )!.matrix{[ 1 .. NrRows( M ) ]}{plist} );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix was created using UnionOfRows (6.5-5) then the filter HasEvalUnionOfRows for A is set to true and the homalgTable function UnionOfRows (D.1-8) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (HasEvalUnionOfRows)",
[ IsHomalgMatrix and HasEvalUnionOfRows ],
function( C )
local R, RP, e, A, B, U;
R := HomalgRing( C );
RP := homalgTable( R );
e := EvalUnionOfRows( C );
A := e[1];
B := e[2];
if IsBound(RP!.UnionOfRows) then
return RP!.UnionOfRows( A, B );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called UnionOfRows in the ",
"homalgTable to apply to a non-internal matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
U := ShallowCopy( Eval( A )!.matrix );
U{ [ NrRows( A ) + 1 .. NrRows( A ) + NrRows( B ) ] } := Eval( B )!.matrix;
return homalgInternalMatrixHull( U );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix was created using UnionOfColumns (6.5-6) then the filter HasEvalUnionOfColumns for A is set to true and the homalgTable function UnionOfColumns (D.1-9) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (HasEvalUnionOfColumns)",
[ IsHomalgMatrix and HasEvalUnionOfColumns ],
function( C )
local R, RP, e, A, B, U;
R := HomalgRing( C );
RP := homalgTable( R );
e := EvalUnionOfColumns( C );
A := e[1];
B := e[2];
if IsBound(RP!.UnionOfColumns) then
return RP!.UnionOfColumns( A, B );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called UnionOfColumns in the ",
"homalgTable to apply to a non-internal matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
U := List( Eval( A )!.matrix, ShallowCopy );
U{ [ 1 .. NrRows( A ) ] }
{ [ NrColumns( A ) + 1 .. NrColumns( A ) + NrColumns( B ) ] }
:= Eval( B )!.matrix;
return homalgInternalMatrixHull( U );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix was created using DiagMat (6.5-7) then the filter HasEvalDiagMat for A is set to true and the homalgTable function DiagMat (D.1-10) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (HasEvalDiagMat)",
[ IsHomalgMatrix and HasEvalDiagMat ],
function( C )
local R, RP, e, z, m, n, diag, mat;
R := HomalgRing( C );
RP := homalgTable( R );
e := EvalDiagMat( C );
if IsBound(RP!.DiagMat) then
return RP!.DiagMat( e );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called DiagMat in the ",
"homalgTable to apply to a non-internal matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
z := Zero( R );
m := Sum( List( e, NrRows ) );
n := Sum( List( e, NrColumns ) );
diag := List( [ 1 .. m ], a -> List( [ 1 .. n ], b -> z ) );
m := 0;
n := 0;
for mat in e do
diag{ [ m + 1 .. m + NrRows( mat ) ] }{ [ n + 1 .. n + NrColumns( mat ) ] }
:= Eval( mat )!.matrix;
m := m + NrRows( mat );
n := n + NrColumns( mat );
od;
return homalgInternalMatrixHull( diag );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix was created using KroneckerMat (6.5-8) then the filter HasEvalKroneckerMat for A is set to true and the homalgTable function KroneckerMat (D.1-11) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (HasEvalKroneckerMat)",
[ IsHomalgMatrix and HasEvalKroneckerMat ],
function( C )
local R, RP, A, B;
R := HomalgRing( C );
if HasIsCommutative( R ) and not IsCommutative( R ) then
Info( InfoWarning, 1, "\033[01m\033[5;31;47m",
"the Kronecker product is only defined for commutative rings!",
"\033[0m" );
fi;
RP := homalgTable( R );
A := EvalKroneckerMat( C )[1];
B := EvalKroneckerMat( C )[2];
if IsBound(RP!.KroneckerMat) then
return RP!.KroneckerMat( A, B );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called KroneckerMat in the ",
"homalgTable to apply to a non-internal matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return homalgInternalMatrixHull(
KroneckerProduct( Eval( A )!.matrix, Eval( B )!.matrix ) );
## this was easy, thanks GAP :)
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix was created using \* (6.5-9) then the filter HasEvalMulMat for A is set to true and the homalgTable function MulMat (D.1-12) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (HasEvalMulMat)",
[ IsHomalgMatrix and HasEvalMulMat ],
function( C )
local R, RP, e, a, A;
R := HomalgRing( C );
RP := homalgTable( R );
e := EvalMulMat( C );
a := e[1];
A := e[2];
if IsBound(RP!.MulMat) then
return RP!.MulMat( a, A );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called MulMat in the ",
"homalgTable to apply to a non-internal matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return a * Eval( A );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix was created using \+ (6.5-10) then the filter HasEvalAddMat for A is set to true and the homalgTable function AddMat (D.1-13) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (HasEvalAddMat)",
[ IsHomalgMatrix and HasEvalAddMat ],
function( C )
local R, RP, e, A, B;
R := HomalgRing( C );
RP := homalgTable( R );
e := EvalAddMat( C );
A := e[1];
B := e[2];
if IsBound(RP!.AddMat) then
return RP!.AddMat( A, B );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called AddMat in the ",
"homalgTable to apply to a non-internal matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return Eval( A ) + Eval( B );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix was created using \- (6.5-11) then the filter HasEvalSubMat for A is set to true and the homalgTable function SubMat (D.1-14) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (HasEvalSubMat)",
[ IsHomalgMatrix and HasEvalSubMat ],
function( C )
local R, RP, e, A, B;
R := HomalgRing( C );
RP := homalgTable( R );
e := EvalSubMat( C );
A := e[1];
B := e[2];
if IsBound(RP!.SubMat) then
return RP!.SubMat( A, B );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called SubMat in the ",
"homalgTable to apply to a non-internal matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return Eval( A ) - Eval( B );
end );
|
> Eval( C ) | ( method ) |
Returns: the Eval value of a homalg matrix C
In case the matrix was created using \* (6.5-12) then the filter HasEvalCompose for A is set to true and the homalgTable function Compose (D.1-15) will be used to set the attribute Eval.
InstallMethod( Eval,
"for homalg matrices (HasEvalCompose)",
[ IsHomalgMatrix and HasEvalCompose ],
function( C )
local R, RP, e, A, B;
R := HomalgRing( C );
RP := homalgTable( R );
e := EvalCompose( C );
A := e[1];
B := e[2];
if IsBound(RP!.Compose) then
return RP!.Compose( A, B );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called Compose in the ",
"homalgTable to apply to a non-internal matrix\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return Eval( A ) * Eval( B );
end );
|
> Eval( A ) | ( method ) |
Returns: see below
In case the matrix was created using LeftInverse (6.4-13) then the filter HasEvalLeftInverse for A is set to true and the method listed below will be used to set the attribute Eval. (--> RightDivide (6.5-40))
InstallMethod( Eval,
"for homalg matrices",
[ IsHomalgMatrix and HasEvalLeftInverse ],
function( LI )
local R, RI, Id, left_inv;
R := HomalgRing( LI );
RI := EvalLeftInverse( LI );
Id := HomalgIdentityMatrix( NrColumns( RI ), R );
left_inv := RightDivide( Id, RI ); ## ( cf. [BR, Subsection 3.1.3] )
if IsBool( left_inv ) then
return false;
fi;
## CAUTION: for the following SetXXX RightDivide is assumed
## NOT to be lazy evaluated!!!
SetIsLeftInvertibleMatrix( RI, true );
if HasIsInvertibleMatrix( RI ) and IsInvertibleMatrix( RI ) then
SetIsInvertibleMatrix( LI, true );
else
SetIsRightInvertibleMatrix( LI, true );
fi;
return Eval( left_inv );
end );
|
> Eval( A ) | ( method ) |
Returns: see below
In case the matrix was created using RightInverse (6.4-14) then the filter HasEvalRightInverse for A is set to true and the method listed below will be used to set the attribute Eval. (--> LeftDivide (6.5-41))
InstallMethod( Eval,
"for homalg matrices",
[ IsHomalgMatrix and HasEvalRightInverse ],
function( RI )
local R, LI, Id, right_inv;
R := HomalgRing( RI );
LI := EvalRightInverse( RI );
Id := HomalgIdentityMatrix( NrRows( LI ), R );
right_inv := LeftDivide( LI, Id ); ## ( cf. [BR, Subsection 3.1.3] )
if IsBool( right_inv ) then
return false;
fi;
## CAUTION: for the following SetXXX LeftDivide is assumed
## NOT to be lazy evaluated!!!
SetIsRightInvertibleMatrix( LI, true );
if HasIsInvertibleMatrix( LI ) and IsInvertibleMatrix( LI ) then
SetIsInvertibleMatrix( RI, true );
else
SetIsLeftInvertibleMatrix( RI, true );
fi;
return Eval( right_inv );
end );
|
generated by GAPDoc2HTML