Skip to content

Commit

Permalink
Distinguish between small and big integers
Browse files Browse the repository at this point in the history
  • Loading branch information
zickgraf committed Jul 18, 2024
1 parent 6cfa137 commit c0c2cb9
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CAP/gap/InstallAdds.gi
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ InstallGlobalFunction( CapInternalInstallAdd,

fi;

InstallMethod( CAP_operation, replaced_filter_list{[ 2 .. Length( replaced_filter_list ) ]}, get_convenience_function( CAP_operation ) );
InstallOtherMethod( CAP_operation, replaced_filter_list{[ 2 .. Length( replaced_filter_list ) ]}, get_convenience_function( CAP_operation ) );

fi;

Expand Down
2 changes: 1 addition & 1 deletion CAP/gap/ToolsForCategories.gi
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ InstallGlobalFunction( "CAP_INTERNAL_GET_DATA_TYPE_FROM_STRING", function ( stri

elif string = "integer" then

return rec( filter := IsInt );
return rec( filter := IsSmallIntRep );

elif string = "nonneg_integer_or_infinity" then

Expand Down
3 changes: 3 additions & 0 deletions CompilerForCAP/gap/CompilerForCAP.gi
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ InstallGlobalFunction( CAP_JIT_INTERNAL_COMPILED_ENHANCED_SYNTAX_TREE, function

# resolving phase
resolving_phase_functions := [
CapJitInferredDataTypes,
CapJitResolvedOperations,
CapJitInlinedArguments,
CapJitDroppedUnusedBindings,
Expand Down Expand Up @@ -380,6 +381,8 @@ InstallGlobalFunction( CAP_JIT_INTERNAL_COMPILED_ENHANCED_SYNTAX_TREE, function

fi;

#Display(ENHANCED_SYNTAX_TREE_CODE( tree ) );

tree := f( tree );

if CAP_JIT_INTERNAL_DEBUG_LEVEL >= 2 then
Expand Down
20 changes: 18 additions & 2 deletions CompilerForCAP/gap/InferDataTypes.gi
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ InstallGlobalFunction( "CAP_JIT_INTERNAL_GET_OUTPUT_TYPE_OF_GLOBAL_FUNCTION_BY_I

if Length( type_signatures ) = 0 then

DisplayWithCurrentlyCompiledFunctionLocation( Concatenation( "WARNING: Could not find matching declaration of ", gvar, " for input ", String( input_filters ) ) );
ErrorWithCurrentlyCompiledFunctionLocation( Concatenation( "WARNING: Could not find matching declaration of ", gvar, " for input ", String( input_filters ) ) );
return fail;

elif Length( type_signatures ) > 1 then
Expand Down Expand Up @@ -428,7 +428,7 @@ InstallGlobalFunction( CAP_JIT_INTERNAL_INFERRED_DATA_TYPES, function ( tree, in

if tree.type = "EXPR_INT" then

data_type := rec( filter := IsInt );
data_type := rec( filter := IsSmallIntRep );

elif tree.type = "EXPR_STRING" then

Expand Down Expand Up @@ -519,6 +519,7 @@ InstallGlobalFunction( CAP_JIT_INTERNAL_INFERRED_DATA_TYPES, function ( tree, in

elif tree.type = "EXPR_RANGE" then

# TODO
data_type := CapJitDataTypeOfListOf( IsInt );

elif tree.type = "EXPR_LIST" then
Expand Down Expand Up @@ -888,9 +889,17 @@ CapJitAddTypeSignature( "RETURN_TRUE", [ IsObject, IsObject ], IsBool );
CapJitAddTypeSignature( "Length", [ IsList ], IsInt );
CapJitAddTypeSignature( "IsEmpty", [ IsList ], IsBool );
CapJitAddTypeSignature( "+", [ IsInt, IsInt ], IsInt );
CapJitAddTypeSignature( "+", [ IsInt, IsSmallIntRep ], IsInt );
CapJitAddTypeSignature( "+", [ IsSmallIntRep, IsSmallIntRep ], IsSmallIntRep );
CapJitAddTypeSignature( "+", [ IsSmallIntRep, IsInt ], IsInt );
CapJitAddTypeSignature( "AdditiveInverseSameMutability", [ IsInt ], IsInt );
CapJitAddTypeSignature( "-", [ IsInt, IsInt ], IsInt );
CapJitAddTypeSignature( "-", [ IsInt, IsSmallIntRep ], IsInt );
CapJitAddTypeSignature( "-", [ IsSmallIntRep, IsSmallIntRep ], IsSmallIntRep );
CapJitAddTypeSignature( "*", [ IsInt, IsInt ], IsInt );
CapJitAddTypeSignature( "*", [ IsInt, IsSmallIntRep ], IsInt );
CapJitAddTypeSignature( "*", [ IsSmallIntRep, IsInt ], IsInt );
CapJitAddTypeSignature( "*", [ IsSmallIntRep, IsSmallIntRep ], IsInt );
CapJitAddTypeSignature( "^", [ IsInt, IsInt ], IsInt );
CapJitAddTypeSignature( "REM_INT", [ IsInt, IsInt ], IsInt );
CapJitAddTypeSignature( "QUO_INT", [ IsInt, IsInt ], IsInt );
Expand All @@ -900,6 +909,7 @@ CapJitAddTypeSignature( "^", [ IsPerm, IsInt ], IsPerm );
CapJitAddTypeSignature( "PermList", [ IsList ], IsPerm );
CapJitAddTypeSignature( "PermutationMat", [ IsPerm, IsInt ], CapJitDataTypeOfListOf( CapJitDataTypeOfListOf( IsInt ) ) );
CapJitAddTypeSignature( "BigInt", [ IsInt ], IsBigInt );
CapJitAddTypeSignature( "BigInt", [ IsSmallIntRep ], IsInt );

CapJitAddTypeSignature( "IS_IDENTICAL_OBJ", [ IsObject, IsObject ], function ( input_types )

Expand Down Expand Up @@ -1019,6 +1029,12 @@ CapJitAddTypeSignature( "[]", [ IsList, IsInt ], function ( input_types )

end );

CapJitAddTypeSignature( "[]", [ IsList, IsSmallIntRep ], function ( input_types )

return input_types[1].element_type;

end );

CapJitAddTypeSignature( "{}", [ IsList, IsList ], function ( input_types )

return input_types[1];
Expand Down
4 changes: 2 additions & 2 deletions FreydCategoriesForCAP/gap/AdditiveClosure.gi
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_ADDITIVE_CLOSURE,
function( cat, diagram, test_object, morphisms, direct_sum )
local listlist;

listlist := UnionOfColumnsListList( Length( ObjectList( test_object ) ), List( morphisms, tau -> MorphismMatrix( tau ) ) );
listlist := UnionOfColumnsListList( BigInt( Length( ObjectList( test_object ) ) ), List( morphisms, tau -> MorphismMatrix( tau ) ) );

return AdditiveClosureMorphism( cat, test_object,
listlist,
Expand All @@ -923,7 +923,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_ADDITIVE_CLOSURE,
function( cat, diagram, test_object, morphisms, direct_sum )
local listlist;

listlist := UnionOfRowsListList( Length( ObjectList( test_object ) ), List( morphisms, tau -> MorphismMatrix( tau ) ) );
listlist := UnionOfRowsListList( BigInt( Length( ObjectList( test_object ) ) ), List( morphisms, tau -> MorphismMatrix( tau ) ) );

return AdditiveClosureMorphism( cat, direct_sum,
listlist,
Expand Down
6 changes: 3 additions & 3 deletions FreydCategoriesForCAP/gap/CategoryOfRows.gi
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CATEGORY_OF_ROWS,
AddAdditiveGenerators( category,
function( cat )

return [ CategoryOfRowsObject( cat, 1 ) ];
return [ CategoryOfRowsObject( cat, BigInt( 1 ) ) ];

end );

Expand Down Expand Up @@ -1013,7 +1013,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_CATEGORY_OF_ROWS,
AddTensorUnit( category,
function( cat )

return CategoryOfRowsObject( cat, 1 );
return CategoryOfRowsObject( cat, BigInt( 1 ) );

end );

Expand Down Expand Up @@ -1364,7 +1364,7 @@ AddFinalDerivationBundle( "Using BasisOfExternalHom and CoefficientsOfMorphism t
[ ],
function ( cat )

return CategoryOfRowsObject( RangeCategoryOfHomomorphismStructure( cat ), 1 );
return CategoryOfRowsObject( RangeCategoryOfHomomorphismStructure( cat ), BigInt( 1 ) );

end
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ InstallMethod( CategoryOfRows_as_AdditiveClosure_RingAsCategory,

modeling_tower_object_datum := function ( cat, object )

return Length( ObjectList( object ) );
return BigInt( Length( ObjectList( object ) ) );

end;

Expand Down

0 comments on commit c0c2cb9

Please sign in to comment.