Skip to content

Commit

Permalink
Merge pull request #1477 from zickgraf/tmp
Browse files Browse the repository at this point in the history
Further improve compilability of LinearClosure
  • Loading branch information
zickgraf authored Oct 3, 2023
2 parents aab6dab + d7a8c2c commit 1ec4f9f
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CompilerForCAP/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "CompilerForCAP",
Subtitle := "Speed up computations in CAP categories",
Version := "2023.10-01",
Version := "2023.10-02",
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
7 changes: 7 additions & 0 deletions CompilerForCAP/gap/InferDataTypes.gi
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ InstallGlobalFunction( "CAP_JIT_INTERNAL_GET_DATA_TYPE_OF_VALUE", function ( val

return CapJitDataTypeOfMorphismOfCategory( CapCategory( value ) );

elif IsBoundGlobal( "IsQuiverVertex" ) and ValueGlobal( "IsQuiverVertex" )( value ) then

# Every quiver vertex also lies in IsPath, which is listed in CAP_JIT_INTERNAL_GLOBAL_VARIABLE_FILTERS.
# We want to strictly distinguish between vertices and paths (see QuiverVertexAsIdentityPath),
# so we have to handle quiver vertices as a special case here.
return rec( filter := ValueGlobal( "IsQuiverVertex" ) );

fi;

filters := Filtered( CAP_JIT_INTERNAL_GLOBAL_VARIABLE_FILTERS, filter -> filter( value ) );
Expand Down
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 := "2023.10-01",
Version := "2023.10-02",
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
36 changes: 36 additions & 0 deletions FreydCategoriesForCAP/gap/LinearClosure.gd
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,24 @@ DeclareOperation( "LinearClosureObject",
DeclareOperation( "LinearClosureObject",
[ IsLinearClosure, IsCapCategoryObject ] );

CapJitAddTypeSignature( "LinearClosureObject", [ IsLinearClosure, IsCapCategoryObject ], function ( input_types )

return CapJitDataTypeOfObjectOfCategory( input_types[1].category );

end );

DeclareOperation( "LinearClosureMorphism",
[ IsLinearClosureObject, IsList, IsList, IsLinearClosureObject ] );

DeclareOperation( "LinearClosureMorphismNC",
[ IsLinearClosureObject, IsList, IsList, IsLinearClosureObject ] );

CapJitAddTypeSignature( "LinearClosureMorphismNC", [ IsLinearClosure, IsLinearClosureObject, IsList, IsList, IsLinearClosureObject ], function ( input_types )

return CapJitDataTypeOfMorphismOfCategory( input_types[1].category );

end );

####################################
##
#! @Section Attributes
Expand All @@ -67,18 +79,42 @@ DeclareOperation( "LinearClosureMorphismNC",
DeclareAttribute( "UnderlyingCategory",
IsLinearClosure );

CapJitAddTypeSignature( "UnderlyingCategory", [ IsLinearClosure ], function ( input_types )

return CapJitDataTypeOfCategory( UnderlyingCategory( input_types[1].category ) );

end );

DeclareAttribute( "UnderlyingRing",
IsLinearClosure );

DeclareAttribute( "UnderlyingOriginalObject",
IsLinearClosureObject );

CapJitAddTypeSignature( "UnderlyingOriginalObject", [ IsLinearClosureObject ], function ( input_types )

Assert( 0, IsLinearClosure( input_types[1].category ) );

return CapJitDataTypeOfObjectOfCategory( UnderlyingCategory( input_types[1].category ) );

end );

DeclareAttribute( "CoefficientsList",
IsLinearClosureMorphism );

CapJitAddTypeSignature( "CoefficientsList", [ IsLinearClosureMorphism ], CapJitDataTypeOfListOf( IsHomalgRingElement ) );

DeclareAttribute( "SupportMorphisms",
IsLinearClosureMorphism );

CapJitAddTypeSignature( "SupportMorphisms", [ IsLinearClosureMorphism ], function ( input_types )

Assert( 0, IsLinearClosure( input_types[1].category ) );

return CapJitDataTypeOfListOf( CapJitDataTypeOfMorphismOfCategory( UnderlyingCategory( input_types[1].category ) ) );

end );

####################################
##
#! @Section Functors
Expand Down
36 changes: 34 additions & 2 deletions FreydCategoriesForCAP/gap/LinearClosure.gi
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ InstallMethod( TwistedLinearClosure,
end );

##
InstallMethod( LinearClosureObject,
[ IsLinearClosure, IsCapCategoryObject ],
InstallMethodForCompilerForCAP( LinearClosureObject,
[ IsLinearClosure, IsCapCategoryObject ],

function( category, object )

Expand Down Expand Up @@ -380,6 +380,38 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_LINEAR_CLOSURE,

fi;

##
AddObjectConstructor( category,
function( cat, underlying_object )

return LinearClosureObject( cat, underlying_object );

end );

##
AddObjectDatum( category,
function( cat, object )

return UnderlyingOriginalObject( object );

end );

##
AddMorphismConstructor( category,
function( cat, source, pair, range )

return LinearClosureMorphismNC( cat, source, pair[1], pair[2], range );

end );

##
AddMorphismDatum( category,
function( cat, morphism )

return Pair( CoefficientsList( morphism ), SupportMorphisms( morphism ) );

end );

##
AddIsEqualForObjects( category, {cat, a, b} -> IsEqualForObjects( UnderlyingOriginalObject( a ), UnderlyingOriginalObject( b ) ) );

Expand Down

0 comments on commit 1ec4f9f

Please sign in to comment.