Skip to content

Commit

Permalink
Merge pull request #1506 from zickgraf/master
Browse files Browse the repository at this point in the history
Use `RingFilter` and `RingElementFilter`
  • Loading branch information
zickgraf authored Nov 30, 2023
2 parents 0d99008 + fe889d7 commit b753fd2
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 37 deletions.
4 changes: 2 additions & 2 deletions CAP/PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SetPackageInfo( rec(

PackageName := "CAP",
Subtitle := "Categories, Algorithms, Programming",
Version := "2023.10-07",
Version := "2023.11-01",
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 Expand Up @@ -97,7 +97,7 @@ PackageDoc := rec(

Dependencies := rec(
GAP := ">= 4.12.1",
NeededOtherPackages := [ [ "ToolsForHomalg", ">= 2023.07-01" ],
NeededOtherPackages := [ [ "ToolsForHomalg", ">= 2023.11-01" ],
],
SuggestedOtherPackages := [ [ "Browse", ">= 1.5" ],
[ "CompilerForCAP", ">= 2021.12-05" ],
Expand Down
26 changes: 4 additions & 22 deletions CAP/gap/ToolsForCategories.gi
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ InstallGlobalFunction( "CAP_INTERNAL_GET_DATA_TYPE_FROM_STRING", function ( stri

ring := CommutativeRingOfLinearCategory( category );

if IsBoundGlobal( "IsHomalgRing" ) and ValueGlobal( "IsHomalgRing" )( ring ) then
if HasRingElementFilter( ring ) then

is_ring_element := ValueGlobal( "IsHomalgRingElement" );
is_ring_element := RingElementFilter( ring );

else

Expand Down Expand Up @@ -198,9 +198,9 @@ InstallGlobalFunction( "CAP_INTERNAL_GET_DATA_TYPE_FROM_STRING", function ( stri

ring := CommutativeRingOfLinearCategory( category );

if IsBoundGlobal( "IsHomalgRing" ) and ValueGlobal( "IsHomalgRing" )( ring ) then
if HasRingElementFilter( ring ) then

is_ring_element := ValueGlobal( "IsHomalgRingElement" );
is_ring_element := RingElementFilter( ring );

else

Expand Down Expand Up @@ -293,11 +293,6 @@ InstallGlobalFunction( CAP_INTERNAL_REPLACED_STRING_WITH_FILTER,
# However, on the GAP level tuples are just dense lists.
return IsDenseList;

elif IsBoundGlobal( "IsHomalgRingElement" ) and IsSpecializationOfFilter( ValueGlobal( "IsHomalgRingElement" ), data_type.filter ) then

# Some things (e.g. integers) do not lie in the filter `IsHomalgRingElement` but are actually elements of homalg rings (e.g. `HomalgRingOfIntegers( )`).
return IsRingElement;

else

return data_type.filter;
Expand Down Expand Up @@ -558,19 +553,6 @@ InstallGlobalFunction( "CAP_INTERNAL_ASSERT_VALUE_IS_OF_TYPE_GETTER",

end;

elif IsBoundGlobal( "IsHomalgRingElement" ) and IsSpecializationOfFilter( ValueGlobal( "IsHomalgRingElement" ), filter ) then

return function( value )

# Some things (e.g. integers) do not lie in the filter `IsHomalgRingElement` but are actually elements of homalg rings (e.g. `HomalgRingOfIntegers( )`).
if not IsRingElement( value ) then

CallFuncList( Error, Concatenation( human_readable_identifier_list, [ " does not lie in the expected filter IsRingElement.", generic_help_string ] ) );

fi;

end;

else

return function( value )
Expand Down
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-05",
Version := "2023.11-01",
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ LoadPackage( "LinearAlgebraForCAP", false );
ReadPackage( "LinearAlgebraForCAP", "gap/CompilerLogic.gi" );
#! true

QQ := HomalgFieldOfRationals( );;
QQ := HomalgFieldOfRationalsInSingular( );;

category_constructor := field -> MatrixCategoryAsCategoryOfRows( field );;
given_arguments := [ QQ ];;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
LoadPackage( "LinearAlgebraForCAP", false );
#! true

QQ := HomalgFieldOfRationals( );;
QQ := HomalgFieldOfRationalsInSingular( );;

# be careful not to use `MatrixCategory` because attributes are not supported
category_constructor := function( field )
Expand Down
12 changes: 7 additions & 5 deletions CompilerForCAP/gap/InferDataTypes.gi
Original file line number Diff line number Diff line change
Expand Up @@ -909,9 +909,9 @@ CapJitAddTypeSignature( "CommutativeRingOfLinearCategory", [ IsCapCategory ], fu

ring := CommutativeRingOfLinearCategory( input_types[1].category );

if IsBoundGlobal( "IsHomalgRing" ) and ValueGlobal( "IsHomalgRing" )( ring ) then
if HasRingFilter( ring ) then

return rec( filter := ValueGlobal( "IsHomalgRing" ) );
return rec( filter := RingFilter( ring ) );

else

Expand Down Expand Up @@ -1569,28 +1569,30 @@ CapJitAddTypeSignature( "Iterated", [ IsList, IsFunction, IsObject, IsObject ],
end );

# homalg operations
# These rules only hold for external homalg rings.
# For example, `Zero( HomalgRingOfIntegers( ) )` does not lie in `IsHomalgRingElement`.
CapJitAddTypeSignatureDeferred( "MatricesForHomalg", "ZeroImmutable", [ "IsHomalgRing" ], "IsHomalgRingElement" );
CapJitAddTypeSignatureDeferred( "MatricesForHomalg", "OneImmutable", [ "IsHomalgRing" ], "IsHomalgRingElement" );

CapJitAddTypeSignatureDeferred( "MatricesForHomalg", "HomalgMatrix", [ "IsList", "IsInt", "IsInt", "IsHomalgRing" ], "IsHomalgMatrix" );
CapJitAddTypeSignatureDeferred( "MatricesForHomalg", "HomalgMatrixListList", [ "IsList", "IsInt", "IsInt", "IsHomalgRing" ], """function( input_types )
Assert( 0, input_types[1].element_type.filter = IsList );
Assert( 0, input_types[1].element_type.element_type.filter in [ IsHomalgRingElement, IsInt, IsRat ] );
Assert( 0, input_types[1].element_type.element_type.filter = IsHomalgRingElement );
return rec( filter := IsHomalgMatrix );
end""" );
CapJitAddTypeSignatureDeferred( "MatricesForHomalg", "HomalgRowVector", [ "IsList", "IsInt", "IsHomalgRing" ], """function( input_types )
Assert( 0, input_types[1].element_type.filter in [ IsHomalgRingElement, IsInt, IsRat ] );
Assert( 0, input_types[1].element_type.filter = IsHomalgRingElement );
return rec( filter := IsHomalgMatrix );
end""" );
CapJitAddTypeSignatureDeferred( "MatricesForHomalg", "HomalgColumnVector", [ "IsList", "IsInt", "IsHomalgRing" ], """function( input_types )
Assert( 0, input_types[1].element_type.filter in [ IsHomalgRingElement, IsInt, IsRat ] );
Assert( 0, input_types[1].element_type.filter = IsHomalgRingElement );
return rec( filter := IsHomalgMatrix );
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.11-03",
Version := "2023.11-04",
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
8 changes: 4 additions & 4 deletions FreydCategoriesForCAP/gap/RingsAsAbCats.gd
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ DeclareAttribute( "UnderlyingRingElement",
IsRingAsCategoryMorphism );
CapJitAddTypeSignature( "UnderlyingRingElement", [ IsRingAsCategoryMorphism ], function ( input_types )

if IsHomalgRing( UnderlyingRing( input_types[1].category ) ) then
if HasRingElementFilter( UnderlyingRing( input_types[1].category ) ) then

return rec( filter := IsHomalgRingElement );
return rec( filter := RingElementFilter( UnderlyingRing( input_types[1].category ) ) );

else

Expand All @@ -80,9 +80,9 @@ DeclareAttribute( "UnderlyingRing",

CapJitAddTypeSignature( "UnderlyingRing", [ IsRingAsCategory ], function ( input_types )

if IsHomalgRing( UnderlyingRing( input_types[1].category ) ) then
if HasRingFilter( UnderlyingRing( input_types[1].category ) ) then

return rec( filter := IsHomalgRing );
return rec( filter := RingFilter( UnderlyingRing( input_types[1].category ) ) );

else

Expand Down

0 comments on commit b753fd2

Please sign in to comment.