Skip to content

Commit

Permalink
Merge pull request #729 from zickgraf/ConvertMatrixToRow
Browse files Browse the repository at this point in the history
Use ConvertMatrixToRow/Column in MatrixCategory and CategoryOfRows/Columns
  • Loading branch information
zickgraf authored Oct 22, 2021
2 parents 0342ca4 + 592397a commit 0880c2a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 62 deletions.
2 changes: 1 addition & 1 deletion FreydCategoriesForCAP/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "FreydCategoriesForCAP",
Subtitle := "Freyd categories - Formal (co)kernels for additive categories",
Version := "2021.10-02",
Version := "2021.10-03",
Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ),
License := "GPL-2.0-or-later",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CATEGORY_OF_COLUMNS_AS_OPPOSITE_OF_
id := HomalgIdentityMatrix( rank, ring );

return CategoryOfColumnsMorphism( cat, tensor_object,
UnionOfColumns( List( [ 1 .. rank ], i -> CertainRows( id, [i] ) ) ),
ConvertMatrixToRow( id ),
unit );

end );
Expand All @@ -308,7 +308,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CATEGORY_OF_COLUMNS_AS_OPPOSITE_OF_
id := HomalgIdentityMatrix( rank, ring );

return CategoryOfColumnsMorphism( cat, unit,
UnionOfRows( List( [ 1 .. rank ], i -> CertainColumns( id, [i] ) ) ),
ConvertMatrixToColumn( id ),
tensor_object );

end );
Expand Down
4 changes: 2 additions & 2 deletions FreydCategoriesForCAP/gap/CategoryOfRows.gi
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CATEGORY_OF_ROWS,
id := HomalgIdentityMatrix( rank, ring );

return CategoryOfRowsMorphism( cat, tensor_object,
UnionOfRows( List( [ 1 .. rank ], i -> CertainColumns( id, [i] ) ) ),
ConvertMatrixToColumn( id ),
unit );

end );
Expand All @@ -975,7 +975,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CATEGORY_OF_ROWS,
id := HomalgIdentityMatrix( rank, ring );

return CategoryOfRowsMorphism( cat, unit,
UnionOfColumns( List( [ 1 .. rank ], i -> CertainRows( id, [i] ) ) ),
ConvertMatrixToRow( id ),
tensor_object );

end );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,15 @@ end

########
function ( cat_1, s_1, a_1, r_1 )
local cap_jit_hoisted_expression_1_1, cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1;
local cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1;
cap_jit_deduplicated_expression_1_1 := RankOfObject( a_1 );
cap_jit_deduplicated_expression_2_1 := UnderlyingRing( cat_1 );
if cap_jit_deduplicated_expression_1_1 = 0 then
return ObjectifyMorphismWithSourceAndRangeForCAPWithAttributes( rec(
), cat_1, s_1, r_1, UnderlyingMatrix, HomalgZeroMatrix( RankOfObject( r_1 ), RankOfObject( s_1 ), cap_jit_deduplicated_expression_2_1 ) );
else
cap_jit_hoisted_expression_1_1 := HomalgIdentityMatrix( cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1 );
return ObjectifyMorphismWithSourceAndRangeForCAPWithAttributes( rec(
), cat_1, s_1, r_1, UnderlyingMatrix, UnionOfRows( List( [ 1 .. cap_jit_deduplicated_expression_1_1 ], function ( i_2 )
return CertainColumns( cap_jit_hoisted_expression_1_1, [ i_2 ] );
end ) ) );
), cat_1, s_1, r_1, UnderlyingMatrix, ConvertMatrixToColumn( HomalgIdentityMatrix( cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1 ) ) );
fi;
return;
end
Expand Down Expand Up @@ -187,18 +184,15 @@ end

########
function ( cat_1, s_1, a_1, r_1 )
local cap_jit_hoisted_expression_1_1, cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1;
local cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1;
cap_jit_deduplicated_expression_1_1 := RankOfObject( a_1 );
cap_jit_deduplicated_expression_2_1 := UnderlyingRing( cat_1 );
if cap_jit_deduplicated_expression_1_1 = 0 then
return ObjectifyMorphismWithSourceAndRangeForCAPWithAttributes( rec(
), cat_1, s_1, r_1, UnderlyingMatrix, HomalgZeroMatrix( RankOfObject( r_1 ), RankOfObject( s_1 ), cap_jit_deduplicated_expression_2_1 ) );
else
cap_jit_hoisted_expression_1_1 := HomalgIdentityMatrix( cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1 );
return ObjectifyMorphismWithSourceAndRangeForCAPWithAttributes( rec(
), cat_1, s_1, r_1, UnderlyingMatrix, UnionOfColumns( List( [ 1 .. cap_jit_deduplicated_expression_1_1 ], function ( i_2 )
return CertainRows( cap_jit_hoisted_expression_1_1, [ i_2 ] );
end ) ) );
), cat_1, s_1, r_1, UnderlyingMatrix, ConvertMatrixToRow( HomalgIdentityMatrix( cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1 ) ) );
fi;
return;
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,15 @@ end

########
function ( cat_1, s_1, a_1, r_1 )
local cap_jit_hoisted_expression_1_1, cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1;
local cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1;
cap_jit_deduplicated_expression_1_1 := RankOfObject( a_1 );
cap_jit_deduplicated_expression_2_1 := UnderlyingRing( cat_1 );
if cap_jit_deduplicated_expression_1_1 = 0 then
return ObjectifyMorphismWithSourceAndRangeForCAPWithAttributes( rec(
), cat_1, s_1, r_1, UnderlyingMatrix, HomalgZeroMatrix( RankOfObject( r_1 ), RankOfObject( s_1 ), cap_jit_deduplicated_expression_2_1 ) );
else
cap_jit_hoisted_expression_1_1 := HomalgIdentityMatrix( cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1 );
return ObjectifyMorphismWithSourceAndRangeForCAPWithAttributes( rec(
), cat_1, s_1, r_1, UnderlyingMatrix, UnionOfRows( List( [ 1 .. cap_jit_deduplicated_expression_1_1 ], function ( i_2 )
return CertainColumns( cap_jit_hoisted_expression_1_1, [ i_2 ] );
end ) ) );
), cat_1, s_1, r_1, UnderlyingMatrix, ConvertMatrixToColumn( HomalgIdentityMatrix( cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1 ) ) );
fi;
return;
end
Expand Down Expand Up @@ -252,18 +249,15 @@ end

########
function ( cat_1, s_1, a_1, r_1 )
local cap_jit_hoisted_expression_1_1, cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1;
local cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1;
cap_jit_deduplicated_expression_1_1 := RankOfObject( a_1 );
cap_jit_deduplicated_expression_2_1 := UnderlyingRing( cat_1 );
if cap_jit_deduplicated_expression_1_1 = 0 then
return ObjectifyMorphismWithSourceAndRangeForCAPWithAttributes( rec(
), cat_1, s_1, r_1, UnderlyingMatrix, HomalgZeroMatrix( RankOfObject( r_1 ), RankOfObject( s_1 ), cap_jit_deduplicated_expression_2_1 ) );
else
cap_jit_hoisted_expression_1_1 := HomalgIdentityMatrix( cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1 );
return ObjectifyMorphismWithSourceAndRangeForCAPWithAttributes( rec(
), cat_1, s_1, r_1, UnderlyingMatrix, UnionOfColumns( List( [ 1 .. cap_jit_deduplicated_expression_1_1 ], function ( i_2 )
return CertainRows( cap_jit_hoisted_expression_1_1, [ i_2 ] );
end ) ) );
), cat_1, s_1, r_1, UnderlyingMatrix, ConvertMatrixToRow( HomalgIdentityMatrix( cap_jit_deduplicated_expression_1_1, cap_jit_deduplicated_expression_2_1 ) ) );
fi;
return;
end
Expand Down
2 changes: 1 addition & 1 deletion LinearAlgebraForCAP/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "LinearAlgebraForCAP",
Subtitle := "Category of Matrices over a Field for CAP",
Version := "2021.09-02",
Version := "2021.10-01",
Date := Concatenation( "01/", ~.Version{[ 6, 7 ]}, "/", ~.Version{[ 1 .. 4 ]} ),
License := "GPL-2.0-or-later",

Expand Down
52 changes: 16 additions & 36 deletions LinearAlgebraForCAP/gap/LinearAlgebraForCAP.gi
Original file line number Diff line number Diff line change
Expand Up @@ -769,30 +769,20 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_MATRIX_CATEGORY,
##
AddEvaluationForDualWithGivenTensorProduct( category,
function( cat, tensor_object, object, unit )
local dimension, column, zero_column, i;
local dimension, id;

dimension := Dimension( object );

column := [ ];

zero_column := List( [ 1 .. dimension ], i -> 0 );

for i in [ 1 .. dimension - 1 ] do

Add( column, 1 );

Append( column, zero_column );

od;

if dimension > 0 then

Add( column, 1 );

if dimension = 0 then

return ZeroMorphism( cat, tensor_object, unit );

fi;

id := HomalgIdentityMatrix( dimension, homalg_field );

return VectorSpaceMorphism( cat, tensor_object,
HomalgMatrix( column, Dimension( tensor_object ), 1, homalg_field ),
ConvertMatrixToColumn( id ),
unit );

end );
Expand All @@ -801,30 +791,20 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_MATRIX_CATEGORY,
AddCoevaluationForDualWithGivenTensorProduct( category,

function( cat, unit, object, tensor_object )
local dimension, row, zero_row, i;
local dimension, id;

dimension := Dimension( object );

row := [ ];

zero_row := List( [ 1 .. dimension ], i -> 0 );

for i in [ 1 .. dimension - 1 ] do

Add( row, 1 );

Append( row, zero_row );

od;

if dimension > 0 then

Add( row, 1 );

if dimension = 0 then

return ZeroMorphism( cat, unit, tensor_object );

fi;

id := HomalgIdentityMatrix( dimension, homalg_field );

return VectorSpaceMorphism( cat, unit,
HomalgMatrix( row, 1, Dimension( tensor_object ), homalg_field ),
ConvertMatrixToRow( id ),
tensor_object );

end );
Expand Down

0 comments on commit 0880c2a

Please sign in to comment.