GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
LoadPackage( "CAP" );
LoadPackage( "MatricesForHomalg" );
#ProfileFunctionsInGlobalVariables( true );
#ProfileOperationsAndMethods( true );
#ProfileGlobalFunctions( true );
ProfileMethods( IsEqualForCache );
###################################
##
## Types and Representations
##
###################################
DeclareRepresentation( "IsHomalgRationalVectorSpaceRep",
IsCapCategoryObjectRep,
[ ] );
BindGlobal( "TheTypeOfHomalgRationalVectorSpaces",
NewType( TheFamilyOfCapCategoryObjects,
IsHomalgRationalVectorSpaceRep ) );
DeclareRepresentation( "IsHomalgRationalVectorSpaceMorphismRep",
IsCapCategoryMorphismRep,
[ ] );
BindGlobal( "TheTypeOfHomalgRationalVectorSpaceMorphism",
NewType( TheFamilyOfCapCategoryMorphisms,
IsHomalgRationalVectorSpaceMorphismRep ) );
###################################
##
## Attributes
##
###################################
DeclareAttribute( "Dimension",
IsHomalgRationalVectorSpaceRep );
#######################################
##
## Operations
##
#######################################
DeclareOperation( "QVectorSpace",
[ IsInt ] );
DeclareOperation( "VectorSpaceMorphism",
[ IsHomalgRationalVectorSpaceRep, IsObject, IsHomalgRationalVectorSpaceRep ] );
vecspaces := CreateCapCategory( "VectorSpaces" );
SetIsAbelianCategory( vecspaces, true );
VECTORSPACES_FIELD := HomalgFieldOfRationals( );
#######################################
##
## Categorical Implementations
##
#######################################
##
InstallMethod( QVectorSpace,
[ IsInt ],
function( dim )
local space;
space := rec( );
ObjectifyWithAttributes( space, TheTypeOfHomalgRationalVectorSpaces,
Dimension, dim
);
# is this the right place?
Add( vecspaces, space );
return space;
end );
##
InstallMethod( VectorSpaceMorphism,
[ IsHomalgRationalVectorSpaceRep, IsObject, IsHomalgRationalVectorSpaceRep ],
function( source, matrix, range )
local morphism;
if not IsHomalgMatrix( matrix ) then
morphism := HomalgMatrix( matrix, Dimension( source ), Dimension( range ), VECTORSPACES_FIELD );
else
morphism := matrix;
fi;
morphism := rec( morphism := morphism );
ObjectifyWithAttributes( morphism, TheTypeOfHomalgRationalVectorSpaceMorphism,
Source, source,
Range, range
);
Add( vecspaces, morphism );
return morphism;
end );
AddPreCompose( vecspaces,
[ function( mor_left, mor_right )
local composition;
composition := mor_left!.morphism * mor_right!.morphism;
return VectorSpaceMorphism( Source( mor_left ), composition, Range( mor_right ) );
end, [ ] ], 100 );