<h4>C.4 <span class="Heading"><strong class="pkg">COLEM</strong>: Clever Operations for Lazy Evaluated Matrices</span></h4>
<p>Most of the matrix tool operations listed in Appendix <a href="chapB_mj.html#X7988F0AF7D87FD23"><span class="RefLink">B.1</span></a> which return a new matrix are lazy evaluated. The value of a <strong class="pkg">homalg</strong> matrix is stored in the attribute <code class="code">Eval</code>. Below is the list of the installed methods for the attribute <code class="code">Eval</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix <var class="Arg">C</var> was created using <code class="func">HomalgInitialMatrix</code> (<a href="chap5_mj.html#X86D290B084AC6638"><span class="RefLink">5.2-1</span></a>) then the filter <code class="code">IsInitialMatrix</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function (--> <code class="func">InitialMatrix</code> (<a href="chapB_mj.html#X7DBA33F083A317B5"><span class="RefLink">B.1-1</span></a>)) will be used to set the attribute <code class="code">Eval</code> and resets the filter <code class="code">IsInitialMatrix</code>.</p>
<div class="example"><pre>
InstallMethod( Eval, "for homalg matrices (IsInitialMatrix)",
[ IsHomalgMatrix and IsInitialMatrix and
HasNumberRows and HasNumberColumns ],
function( C )
local R, RP, z, zz;
R := HomalgRing( C );
RP := homalgTable( R );
if IsBound( RP!.InitialMatrix ) then
ResetFilterObj( C, IsInitialMatrix );
SetEval( C, RP!.InitialMatrix( C ) );
return Eval( C );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called InitialMatrix 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( NumberColumns( C ), z );
SetEval( C, homalgInternalMatrixHull( List( [ 1 .. NumberRows( C ) ], i -> ShallowCopy( zz ) ) ) );
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix <var class="Arg">C</var> was created using <code class="func">HomalgInitialIdentityMatrix</code> (<a href="chap5_mj.html#X7CB77009868D369A"><span class="RefLink">5.2-2</span></a>) then the filter <code class="code">IsInitialIdentityMatrix</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function (--> <code class="func">InitialIdentityMatrix</code> (<a href="chapB_mj.html#X84179BE87E7DCE76"><span class="RefLink">B.1-2</span></a>)) will be used to set the attribute <code class="code">Eval</code> and resets the filter <code class="code">IsInitialIdentityMatrix</code>.</p>
<div class="example"><pre>
InstallMethod( Eval, "for homalg matrices (IsInitialIdentityMatrix)",
[ IsHomalgMatrix and IsInitialIdentityMatrix and
HasNumberRows and HasNumberColumns ],
function( C )
local R, RP, o, z, zz, id;
R := HomalgRing( C );
RP := homalgTable( R );
if IsBound( RP!.InitialIdentityMatrix ) then
ResetFilterObj( C, IsInitialIdentityMatrix );
SetEval( C, RP!.InitialIdentityMatrix( C ) );
return Eval( C );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called InitialIdentityMatrix 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( NumberColumns( C ), z );
id := List( [ 1 .. NumberRows( C ) ],
function(i)
local z;
z := ShallowCopy( zz ); z[i] := o; return z;
end );
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix <var class="Arg">C</var> was created using <code class="func">HomalgZeroMatrix</code> (<a href="chap5_mj.html#X8309EB7B86953A23"><span class="RefLink">5.2-3</span></a>) then the filter <code class="code">IsZeroMatrix</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function (--> <code class="func">ZeroMatrix</code> (<a href="chapB_mj.html#X785390E38396CAEB"><span class="RefLink">B.1-3</span></a>)) will be used to set the attribute <code class="code">Eval</code>.</p>
<div class="example"><pre>
InstallMethod( Eval, "for homalg matrices (IsZero)",
[ IsHomalgMatrix and IsZero and HasNumberRows and HasNumberColumns ], 40,
function( C )
local R, RP, z;
R := HomalgRing( C );
RP := homalgTable( R );
if ( NumberRows( C ) = 0 or NumberColumns( 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 ", "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( NumberRows( C ),
ListWithIdenticalEntries( NumberColumns( C ), z ) ) );
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix <var class="Arg">C</var> was created using <code class="func">HomalgIdentityMatrix</code> (<a href="chap5_mj.html#X83266B9D7BE740D8"><span class="RefLink">5.2-4</span></a>) then the filter <code class="code">IsOne</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function (--> <code class="func">IdentityMatrix</code> (<a href="chapB_mj.html#X87BFF3567DEEBEF4"><span class="RefLink">B.1-4</span></a>)) will be used to set the attribute <code class="code">Eval</code>.</p>
<div class="example"><pre>
InstallMethod( Eval, "for homalg matrices (IsOne)",
[ IsHomalgMatrix and IsOne and HasNumberRows and HasNumberColumns ], 10,
function( C )
local R, id, RP, o, z, zz;
R := HomalgRing( C );
if IsBound( R!.IdentityMatrices ) then
id := ElmWPObj( R!.IdentityMatrices!.weak_pointers, NumberColumns( C ) );
if id <> fail then
R!.IdentityMatrices!.cache_hits := R!.IdentityMatrices!.cache_hits + 1;
return id;
fi;
## we do not count cache_misses as it is equivalent to counter
fi;
RP := homalgTable( R );
if IsBound( RP!.IdentityMatrix ) then
id := RP!.IdentityMatrix( C );
SetElmWPObj( R!.IdentityMatrices!.weak_pointers, NumberColumns( C ), id );
R!.IdentityMatrices!.counter := R!.IdentityMatrices!.counter + 1;
return id;
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called IdentityMatrix ", "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( NumberColumns( C ), z );
id := List( [ 1 .. NumberRows( C ) ],
function(i)
local z;
z := ShallowCopy( zz ); z[i] := o; return z;
end );
id := homalgInternalMatrixHull( id );
SetElmWPObj( R!.IdentityMatrices!.weak_pointers, NumberColumns( C ), id );
<p>In case the matrix <var class="Arg">LI</var> was created using <code class="func">LeftInverseLazy</code> (<a href="chap5_mj.html#X7A7E42C179142727"><span class="RefLink">5.5-4</span></a>) then the filter <code class="code">HasEvalLeftInverse</code> for <var class="Arg">LI</var> is set to true and the method listed below will be used to set the attribute <code class="code">Eval</code>. (--> <code class="func">LeftInverse</code> (<a href="chap5_mj.html#X7FBAA11B8008D936"><span class="RefLink">5.5-2</span></a>))</p>
<p>In case the matrix <var class="Arg">RI</var> was created using <code class="func">RightInverseLazy</code> (<a href="chap5_mj.html#X7FA3E7617EED7E1E"><span class="RefLink">5.5-5</span></a>) then the filter <code class="code">HasEvalRightInverse</code> for <var class="Arg">RI</var> is set to true and the method listed below will be used to set the attribute <code class="code">Eval</code>. (--> <code class="func">RightInverse</code> (<a href="chap5_mj.html#X7AAD17D47839BCAE"><span class="RefLink">5.5-3</span></a>))</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">Involution</code> (<a href="chap5_mj.html#X800FA81F7C42BFEA"><span class="RefLink">5.5-6</span></a>) then the filter <code class="code">HasEvalInvolution</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">Involution</code> (<a href="chapB_mj.html#X85884C3178473521"><span class="RefLink">B.1-5</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
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 of the non-internal ring\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return homalgInternalMatrixHull( TransposedMat( Eval( M )!.matrix ) );
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">TransposedMatrix</code> (<a href="chap5_mj.html#X7D0D35B582D9C0B0"><span class="RefLink">5.5-7</span></a>) then the filter <code class="code">HasEvalTransposedMatrix</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">TransposedMatrix</code> (<a href="chapB_mj.html#X7AD2EEE680DF472B"><span class="RefLink">B.1-6</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
if IsBound(RP!.TransposedMatrix) then
return RP!.TransposedMatrix( M );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called TransposedMatrix ", "in the homalgTable of the non-internal ring\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return homalgInternalMatrixHull( TransposedMat( Eval( M )!.matrix ) );
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">CoercedMatrix</code> (<a href="chap5_mj.html#X7C4E49D287011DCD"><span class="RefLink">5.2-12</span></a>) then the filter <code class="code">HasEvalCoercedMatrix</code> for <var class="Arg">C</var> is set to true and the <code class="code">Eval</code> value of a copy of <code class="code">EvalCoercedMatrix(</code><var class="Arg">C</var><code class="code">)</code> in <code class="code">HomalgRing(</code><var class="Arg">C</var><code class="code">)</code> will be used to set the attribute <code class="code">Eval</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">CertainRows</code> (<a href="chap5_mj.html#X7CF5CE79796001F6"><span class="RefLink">5.5-8</span></a>) then the filter <code class="code">HasEvalCertainRows</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">CertainRows</code> (<a href="chapB_mj.html#X7B6FC3267CD9EE9D"><span class="RefLink">B.1-7</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
## delete the component which was left over by GAP
Unbind( C!.EvalCertainRows );
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 of the non-internal ring\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return homalgInternalMatrixHull( Eval( M )!.matrix{ plist } );
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">CertainColumns</code> (<a href="chap5_mj.html#X8256AF2A840B19C4"><span class="RefLink">5.5-9</span></a>) then the filter <code class="code">HasEvalCertainColumns</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">CertainColumns</code> (<a href="chapB_mj.html#X78EADFC67D17CF04"><span class="RefLink">B.1-8</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
## delete the component which was left over by GAP
Unbind( C!.EvalCertainColumns );
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 of the non-internal ring\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return homalgInternalMatrixHull(
Eval( M )!.matrix{[ 1 .. NumberRows( M ) ]}{plist} );
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">UnionOfRows</code> (<a href="chap5_mj.html#X7D6D0BDF854C9EBC"><span class="RefLink">5.5-10</span></a>) then the filter <code class="code">HasEvalUnionOfRows</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">UnionOfRows</code> (<a href="chapB_mj.html#X7DEB535782A3323E"><span class="RefLink">B.1-9</span></a>) or the <code class="code">homalgTable</code> function <code class="func">UnionOfRowsPair</code> (<a href="chapB_mj.html#X86C345CE82AAB220"><span class="RefLink">B.1-10</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
# Make it mutable
e := ShallowCopy( EvalUnionOfRows( C ) );
# In case of nested UnionOfRows, we try to avoid
# recursion, since the gap stack is rather small
# additionally unpack PreEvals
i := 1;
while i <= Length( e ) do
if HasPreEval( e[i] ) and not HasEval( e[i] ) then
e[i] := PreEval( e[i] );
elif HasEvalUnionOfRows( e[i] ) and not HasEval( e[i] ) then
e := Concatenation( e{[ 1 .. (i-1) ]}, EvalUnionOfRows( e[i] ), e{[ (i+1) .. Length( e ) ]} );
else
i := i + 1;
fi;
od;
# Combine zero matrices
i := 1;
while i + 1 <= Length( e ) do
if HasIsZero( e[i] ) and IsZero( e[i] ) and HasIsZero( e[i+1] ) and IsZero( e[i+1] ) then
# After combining zero matrices only a single one might be left
if Length( e ) = 1 then
return e[1];
fi;
# Use RP!.UnionOfRows if available
if IsBound(RP!.UnionOfRows) then
return RP!.UnionOfRows( e );
fi;
# Fall back to RP!.UnionOfRowsPair or manual fallback for internal matrices
# Combine the matrices
# Use a balanced binary tree to keep the sizes small (heuristically)
# to avoid a huge memory footprint
if not IsBound(RP!.UnionOfRowsPair) and not IsHomalgInternalMatrixRep( C ) then
Error( "could neither find a procedure called UnionOfRows ", "nor a procedure called UnionOfRowsPair ", "in the homalgTable of the non-internal ring\n" );
fi;
combine := function( A, B )
local result, U;
if IsBound(RP!.UnionOfRowsPair) then
result := RP!.UnionOfRowsPair( A, B );
else
#=====# can only work for homalg internal matrices #=====#
U := ShallowCopy( Eval( A )!.matrix );
U{ [ NumberRows( A ) + 1 .. NumberRows( A ) + NumberRows( B ) ] } := Eval( B )!.matrix;
result := homalgInternalMatrixHull( U );
fi;
return HomalgMatrixWithAttributes( [
Eval, result,
EvalUnionOfRows, [ A, B ],
NumberRows, NumberRows( A ) + NumberRows( B ),
NumberColumns, NumberColumns( A ),
], R );
end;
while Length( e ) > 1 do
for i in [ 1 .. Int( Length( e ) / 2 ) ] do
e[ 2 * i - 1 ] := combine( e[ 2 * i - 1 ], e[ 2 * i ] );
Unbind( e[ 2 * i ] );
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">UnionOfColumns</code> (<a href="chap5_mj.html#X7FF9661D85EC46B1"><span class="RefLink">5.5-11</span></a>) then the filter <code class="code">HasEvalUnionOfColumns</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">UnionOfColumns</code> (<a href="chapB_mj.html#X7DF5DB55836D13A7"><span class="RefLink">B.1-11</span></a>) or the <code class="code">homalgTable</code> function <code class="func">UnionOfColumnsPair</code> (<a href="chapB_mj.html#X8092789C87E37020"><span class="RefLink">B.1-12</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
# Make it mutable
e := ShallowCopy( EvalUnionOfColumns( C ) );
# In case of nested UnionOfColumns, we try to avoid
# recursion, since the gap stack is rather small
# additionally unpack PreEvals
i := 1;
while i <= Length( e ) do
if HasPreEval( e[i] ) and not HasEval( e[i] ) then
e[i] := PreEval( e[i] );
elif HasEvalUnionOfColumns( e[i] ) and not HasEval( e[i] ) then
e := Concatenation( e{[ 1 .. (i-1) ]}, EvalUnionOfColumns( e[i] ), e{[ (i+1) .. Length( e ) ]} );
else
i := i + 1;
fi;
od;
# Combine zero matrices
i := 1;
while i + 1 <= Length( e ) do
if HasIsZero( e[i] ) and IsZero( e[i] ) and HasIsZero( e[i+1] ) and IsZero( e[i+1] ) then
# After combining zero matrices only a single one might be left
if Length( e ) = 1 then
return e[1];
fi;
# Use RP!.UnionOfColumns if available
if IsBound(RP!.UnionOfColumns) then
return RP!.UnionOfColumns( e );
fi;
# Fall back to RP!.UnionOfColumnsPair or manual fallback for internal matrices
# Combine the matrices
# Use a balanced binary tree to keep the sizes small (heuristically)
# to avoid a huge memory footprint
if not IsBound(RP!.UnionOfColumnsPair) and not IsHomalgInternalMatrixRep( C ) then
Error( "could neither find a procedure called UnionOfColumns ", "nor a procedure called UnionOfColumnsPair ", "in the homalgTable of the non-internal ring\n" );
fi;
combine := function( A, B )
local result, U;
if IsBound(RP!.UnionOfColumnsPair) then
result := RP!.UnionOfColumnsPair( A, B );
else
#=====# can only work for homalg internal matrices #=====#
U := List( Eval( A )!.matrix, ShallowCopy );
U{ [ 1 .. NumberRows( A ) ] }
{ [ NumberColumns( A ) + 1 .. NumberColumns( A ) + NumberColumns( B ) ] }
:= Eval( B )!.matrix;
result := homalgInternalMatrixHull( U );
fi;
return HomalgMatrixWithAttributes( [
Eval, result,
EvalUnionOfColumns, [ A, B ],
NumberRows, NumberRows( A ),
NumberColumns, NumberColumns( A ) + NumberColumns( B )
], R );
end;
while Length( e ) > 1 do
for i in [ 1 .. Int( Length( e ) / 2 ) ] do
e[ 2 * i - 1 ] := combine( e[ 2 * i - 1 ], e[ 2 * i ] );
Unbind( e[ 2 * i ] );
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">DiagMat</code> (<a href="chap5_mj.html#X7C7830BE847D84B4"><span class="RefLink">5.5-16</span></a>) then the filter <code class="code">HasEvalDiagMat</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">DiagMat</code> (<a href="chapB_mj.html#X86C5B86981FA1F9A"><span class="RefLink">B.1-13</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
function( C )
local R, RP, e, l, z, m, n, diag, mat;
R := HomalgRing( C );
RP := homalgTable( R );
e := EvalDiagMat( C );
if IsBound(RP!.DiagMat) then
return RP!.DiagMat( e );
fi;
l := Length( e );
if not IsHomalgInternalMatrixRep( C ) then
return UnionOfRows(
List( [ 1 .. l ],
i -> UnionOfColumns(
List( [ 1 .. l ],
function( j )
if i = j then
return e[i];
fi;
return HomalgZeroMatrix( NumberRows( e[i] ), NumberColumns( e[j] ), R );
end )
)
)
);
fi;
#=====# can only work for homalg internal matrices #=====#
z := Zero( R );
m := Sum( List( e, NumberRows ) );
n := Sum( List( e, NumberColumns ) );
diag := List( [ 1 .. m ], a -> List( [ 1 .. n ], b -> z ) );
m := 0;
n := 0;
for mat in e do
diag{ [ m + 1 .. m + NumberRows( mat ) ] }{ [ n + 1 .. n + NumberColumns( mat ) ] }
:= Eval( mat )!.matrix;
m := m + NumberRows( mat );
n := n + NumberColumns( mat );
od;
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">KroneckerMat</code> (<a href="chap5_mj.html#X7CDA5D848468A0AA"><span class="RefLink">5.5-17</span></a>) then the filter <code class="code">HasEvalKroneckerMat</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">KroneckerMat</code> (<a href="chapB_mj.html#X82202A6A7FAB7174"><span class="RefLink">B.1-14</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
if ( HasIsCommutative( R ) and not IsCommutative( R ) ) and
( HasIsSuperCommutative( R ) and not IsSuperCommutative( R ) ) then
Info( InfoWarning, 1, "\033[01m\033[5;31;47m", "the Kronecker product is only defined for (super) 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 of the non-internal ring\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
return homalgInternalMatrixHull(
KroneckerProduct( Eval( A )!.matrix, Eval( B )!.matrix ) );
## this was easy, thanks GAP :)
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">DualKroneckerMat</code> (<a href="chap5_mj.html#X7ECF744B7DE82BED"><span class="RefLink">5.5-18</span></a>) then the filter <code class="code">HasEvalDualKroneckerMat</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">DualKroneckerMat</code> (<a href="chapB_mj.html#X87E0747D7FEEAC76"><span class="RefLink">B.1-15</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
if ( HasIsCommutative( R ) and not IsCommutative( R ) ) and
( HasIsSuperCommutative( R ) and not IsSuperCommutative( R ) ) then
Info( InfoWarning, 1, "\033[01m\033[5;31;47m", "the dual Kronecker product is only defined for (super) commutative rings!", "\033[0m" );
fi;
RP := homalgTable( R );
A := EvalDualKroneckerMat( C )[1];
B := EvalDualKroneckerMat( C )[2];
# work around errors in Singular when taking the opposite ring of a ring with ordering lp
# https://github.com/Singular/Singular/issues/1011
# fixed in version 4.2.0
if IsBound(RP!.DualKroneckerMat) and not (
IsBound( R!.ring ) and
IsBound( R!.ring!.stream ) and
IsBound( R!.ring!.stream.cas ) and R!.ring!.stream.cas = "singular" and
( not IsBound( R!.ring!.stream.version ) or R!.ring!.stream.version < 4200 ) and
IsBound( R!.order ) and IsString( R!.order ) and StartsWith( R!.order, "lex" )
) then
return RP!.DualKroneckerMat( A, B );
fi;
if HasIsCommutative( R ) and IsCommutative( R ) then
return Eval( KroneckerMat( B, A ) );
else
return Eval(
TransposedMatrix( Involution(
KroneckerMat( TransposedMatrix( Involution( B ) ), TransposedMatrix( Involution( A ) ) )
) )
);
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">\*</code> (<a href="chap5_mj.html#X7D1A074278B415BE"><span class="RefLink">5.5-19</span></a>) then the filter <code class="code">HasEvalMulMat</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">MulMat</code> (<a href="chapB_mj.html#X828F8C7785EEC3D1"><span class="RefLink">B.1-16</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
if IsBound(RP!.MulMatRight) then
return RP!.MulMatRight( A, a );
fi;
if not IsHomalgInternalMatrixRep( C ) then
Error( "could not find a procedure called MulMatRight ", "in the homalgTable of the non-internal ring\n" );
fi;
#=====# can only work for homalg internal matrices #=====#
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">\+</code> (<a href="chap5_mj.html#X87C773DA85B21ADF"><span class="RefLink">5.5-20</span></a>) then the filter <code class="code">HasEvalAddMat</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">AddMat</code> (<a href="chapB_mj.html#X7B0B12F080A90039"><span class="RefLink">B.1-17</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">\-</code> (<a href="chap5_mj.html#X784B57617B24208C"><span class="RefLink">5.5-21</span></a>) then the filter <code class="code">HasEvalSubMat</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">SubMat</code> (<a href="chapB_mj.html#X7FE11AA27AE7D2D7"><span class="RefLink">B.1-18</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">\*</code> (<a href="chap5_mj.html#X7F5961D78754157B"><span class="RefLink">5.5-22</span></a>) then the filter <code class="code">HasEvalCompose</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">Compose</code> (<a href="chapB_mj.html#X7D491D957E63C3A4"><span class="RefLink">B.1-19</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ Eval</code>( <var class="Arg">C</var> )</td><td class="tdright">( method )</td></tr></table></div>
<p>Returns: the <code class="code">Eval</code> value of a <strong class="pkg">homalg</strong> matrix <var class="Arg">C</var></p>
<p>In case the matrix was created using <code class="func">CoefficientsWithGivenMonomials</code> (<a href="chap5_mj.html#X7EEFD7887E96714F"><span class="RefLink">5.5-64</span></a>) then the filter <code class="code">HasEvalCoefficientsWithGivenMonomials</code> for <var class="Arg">C</var> is set to true and the <code class="code">homalgTable</code> function <code class="func">CoefficientsWithGivenMonomials</code> (<a href="chapB_mj.html#X8450E904787CBD35"><span class="RefLink">B.1-24</span></a>) will be used to set the attribute <code class="code">Eval</code>.</p>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.