Skip to content

Commit

Permalink
updated LinearAlgebraForCAP/gap/CompilerLogic.gi
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamed-barakat committed Aug 16, 2023
1 parent 6795a14 commit 42f43c1
Show file tree
Hide file tree
Showing 4 changed files with 736 additions and 769 deletions.
6 changes: 3 additions & 3 deletions CompilerForCAP/tst/Logic.tst
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ end

#
gap> func := function ( L1, L2 )
> return List( Concatenation( L1, L2 ), x -> x ); end;;
> return List( Concatenation( L1, L2 ), x -> x^2 ); end;;

#
gap> tree := ENHANCED_SYNTAX_TREE( func );;
gap> tree := CapJitAppliedLogic( tree );;
gap> Display( ENHANCED_SYNTAX_TREE_CODE( tree ) );
function ( L1_1, L2_1 )
return Concatenation( List( L1_1, function ( x_2 )
return x_2;
return x_2 ^ 2;
end ), List( L2_1, function ( x_2 )
return x_2;
return x_2 ^ 2;
end ) );
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 := "2023.08-04",
Version := "2023.08-05",
Date := (function ( ) if IsBound( GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE ) then return GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE; else return Concatenation( ~.Version{[ 1 .. 4 ]}, "-", ~.Version{[ 6, 7 ]}, "-01" ); fi; end)( ),
License := "GPL-2.0-or-later",

Expand Down
199 changes: 199 additions & 0 deletions LinearAlgebraForCAP/gap/CompilerLogic.gi
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,78 @@ CapJitAddLogicTemplate(
)
);

#
CapJitAddLogicTemplate(
rec(
variable_names := [ "n", "ring" ],
src_template := "TransposedMatrix( HomalgIdentityMatrix( n, ring ) )",
dst_template := "HomalgIdentityMatrix( n, ring )",
)
);

#
CapJitAddLogicTemplate(
rec(
variable_names := [ "n", "ring" ],
src_template := "HomalgMatrix( PermutationMat( PermList( [ 1 .. n ] ), n ), n, n, ring )",
dst_template := "HomalgIdentityMatrix( n, ring )",
)
);

#
CapJitAddLogicTemplate(
rec(
variable_names := [ "ring" ],
src_template := "HomalgMatrix( PermutationMat( PermList( [ 1 ] ), 1 ), 1, 1, ring )",
dst_template := "HomalgIdentityMatrix( 1, ring )",
)
);

#
CapJitAddLogicTemplate(
rec(
variable_names := [ "ring", "matrix" ],
src_template := "KroneckerMat( HomalgIdentityMatrix( 1, ring ), matrix )",
dst_template := "matrix",
)
);

#
CapJitAddLogicTemplate(
rec(
variable_names := [ "ring", "matrix" ],
src_template := "KroneckerMat( matrix, HomalgIdentityMatrix( 1, ring ) )",
dst_template := "matrix",
)
);

#
CapJitAddLogicTemplate(
rec(
variable_names := [ "m", "n", "ring" ],
src_template := "KroneckerMat( HomalgIdentityMatrix( m, ring ), HomalgIdentityMatrix( n, ring ) )",
dst_template := "HomalgIdentityMatrix( m * n, ring )",
)
);

#
CapJitAddLogicTemplate(
rec(
variable_names := [ "ring" ],
src_template := "ConvertMatrixToRow( HomalgIdentityMatrix( 1, ring ) )",
dst_template := "HomalgIdentityMatrix( 1, ring )",
)
);

#
CapJitAddLogicTemplate(
rec(
variable_names := [ "ring" ],
src_template := "ConvertMatrixToColumn( HomalgIdentityMatrix( 1, ring ) )",
dst_template := "HomalgIdentityMatrix( 1, ring )",
)
);

# Length( [ 1 .. n ] ) -> n
CapJitAddLogicTemplate(
rec(
Expand All @@ -63,3 +135,130 @@ CapJitAddLogicTemplate(
dst_template := "n"
)
);

# 1 - 1 -> 0
CapJitAddLogicTemplate(
rec(
variable_names := [ ],
src_template := "1 - 1",
dst_template := "0"
)
);

# 0 + n -> n
CapJitAddLogicTemplate(
rec(
variable_names := [ "n" ],
src_template := "0 + n",
dst_template := "n"
)
);

# n + 0 -> n
CapJitAddLogicTemplate(
rec(
variable_names := [ "n" ],
src_template := "n + 0",
dst_template := "n"
)
);

# n - 1 + 1 -> n
CapJitAddLogicTemplate(
rec(
variable_names := [ "n" ],
src_template := "n - 1 + 1",
dst_template := "n"
)
);

# 0 * n -> 0
CapJitAddLogicTemplate(
rec(
variable_names := [ "n" ],
src_template := "0 * n",
dst_template := "0"
)
);

# n * 0 -> 0
CapJitAddLogicTemplate(
rec(
variable_names := [ "n" ],
src_template := "n * 0",
dst_template := "0"
)
);

# 1 * n -> n
CapJitAddLogicTemplate(
rec(
variable_names := [ "n" ],
src_template := "1 * n",
dst_template := "n"
)
);

# n * 1 -> n
CapJitAddLogicTemplate(
rec(
variable_names := [ "n" ],
src_template := "n * 1",
dst_template := "n"
)
);

# QUO_INT( n, 1 ) -> n
CapJitAddLogicTemplate(
rec(
variable_names := [ "n" ],
src_template := "QUO_INT( n, 1 )",
dst_template := "n"
)
);

# REM_INT( n, 1 ) -> n
CapJitAddLogicTemplate(
rec(
variable_names := [ "n" ],
src_template := "REM_INT( n, 1 )",
dst_template := "0"
)
);

# List( [ 1 .. n ], i -> REM_INT( i - 1, n ) + QUO_INT( i - 1, n ) + 1 ) -> [ 1 .. n ]
CapJitAddLogicTemplate(
rec(
variable_names := [ "n" ],
src_template := "List( [ 1 .. n ], i -> REM_INT( i - 1, n ) + QUO_INT( i - 1, n ) + 1 )",
dst_template := "[ 1 .. n ]"
)
);

# list{[ ]} -> [ ]
CapJitAddLogicTemplate(
rec(
variable_names := [ "list" ],
src_template := "list{[ ]}",
dst_template := "[ ]"
)
);

# Sum( [ ] ) -> 0
CapJitAddLogicTemplate(
rec(
variable_names := [ ],
src_template := "Sum( [ ] )",
dst_template := "0"
)
);

# List( list, i -> i ) -> list
CapJitAddLogicTemplate(
rec(
variable_names := [ "list" ],
src_template := "List( list, i -> i )",
dst_template := "list"
)
);

Loading

0 comments on commit 42f43c1

Please sign in to comment.