Goto Chapter: Top 1 2 3 Ind

### 3 Examples and tests

#### 3.1 Examples

gap> LoadPackage( "FreydCategoriesForCAP", false );
true
true
gap> Q := HomalgFieldOfRationals();;
gap> vec := MatrixCategory_as_CategoryOfRows( Q : no_precompiled_code := true );;
gap> V := MatrixCategoryObject( vec, 2 );;
gap> alpha := ZeroMorphism( V, V );;
gap> beta := IdentityMorphism( V );;
gap> W := DirectSum( V, V );;
gap> morphism_matrix := [ [ alpha, beta ], [ beta, alpha ] ];;
gap> # compile the derivation of MorphismBetweenDirectSumsWithGivenDirectSums
> Print(
>     "\n"
> );
function ( cat, S, diagram_S, morphism_matrix, diagram_T, T )
local test_diagram_product, test_diagram_coproduct;
test_diagram_coproduct := ListN( diagram_S, morphism_matrix,
function ( source, row )
return UniversalMorphismIntoDirectSumWithGivenDirectSum( cat,
diagram_T, source, row, T );
end );
return UniversalMorphismFromDirectSumWithGivenDirectSum( cat, diagram_S,
T, test_diagram_coproduct, S );
end
gap> compiled_func2 := CapJitCompiledFunction(
>     vec
> );;
gap> Display( compiled_func2 );
function ( cat_1, S_1, diagram_S_1, morphism_matrix_1, diagram_T_1, T_1 )
local deduped_2_1;
deduped_2_1 := UnderlyingRing( cat_1 );
return AsCapCategoryMorphism( cat_1, S_1,
UnionOfRows( deduped_2_1, AsInteger( T_1 ),
ListN( diagram_S_1, morphism_matrix_1, function ( source_2, row_2 )
return UnionOfColumns( deduped_2_1, AsInteger( source_2 ),
List( row_2, AsHomalgMatrix ) );
end ) ), T_1 );
end
gap> Display( ENHANCED_SYNTAX_TREE_CODE(
>     CapJitCompiledCAPOperationAsEnhancedSyntaxTree(
>         vec, "KernelEmbedding", true
>     )
> ) );
function ( cat_1, alpha_1 )
local morphism_attr_1_1;
morphism_attr_1_1 := SyzygiesOfRows( AsHomalgMatrix( alpha_1 ) );
return
AsCapCategoryMorphism( cat_1,
AsCapCategoryObject( cat_1, NumberRows( morphism_attr_1_1 ) ),
morphism_attr_1_1, Source( alpha_1 ) );
end

gap> LoadPackage( "FreydCategoriesForCAP", false );
true
true
true
gap> CAP_INTERNAL_DUMMY_HOMALG_FIELD_COUNTER := 1;;
gap> homalg_field := DummyHomalgField( );;
gap> category_constructor := field -> MatrixCategory_as_CategoryOfRows( field );;
gap> given_arguments := [ homalg_field ];;
gap> compiled_category_name := "MatrixCategory_precompiled";;
gap> package_name := "LinearAlgebraForCAP";;
gap> CapJitPrecompileCategoryAndCompareResult(
>     category_constructor,
>     given_arguments,
>     package_name,
>     compiled_category_name :
>     number_of_objectified_objects_in_data_structure_of_object := 1,
>     number_of_objectified_morphisms_in_data_structure_of_object := 0,
>     number_of_objectified_objects_in_data_structure_of_morphism := 2,
>     number_of_objectified_morphisms_in_data_structure_of_morphism := 1
> );;
gap> MatrixCategory_precompiled( homalg_field );
Category of matrices over Dummy homalg field 1
true


#### 3.2 Tests

gap> LoadPackage( "FreydCategoriesForCAP", false );
true
true
gap> homalg_field := DummyHomalgField( );;
gap> commutative_homalg_ring := DummyCommutativeHomalgRing( );;
gap> homalg_ring := DummyHomalgRing( );;
gap> QQ := HomalgFieldOfRationalsInSingular( );;
gap> QQxy := QQ * "x,y";;
gap> EQQxy := KoszulDualRing( QQxy );;
gap> precompile_CategoryOfColumns := function( homalg_ring, name )
>
>     CapJitPrecompileCategoryAndCompareResult(
>         homalg_ring -> CategoryOfColumns(
>             homalg_ring
>         ),
>         [ homalg_ring ],
>         "FreydCategoriesForCAP",
>         Concatenation(
>             "CategoryOfColumns_as_Opposite_CategoryOfRows_",
>             name,
>             "_precompiled"
>         ) :
>         operations := "primitive",
>         number_of_objectified_objects_in_data_structure_of_object := 1,
>         number_of_objectified_morphisms_in_data_structure_of_object := 0,
>         number_of_objectified_objects_in_data_structure_of_morphism := 2,
>         number_of_objectified_morphisms_in_data_structure_of_morphism := 1
>     ); end;;
gap> precompile_CategoryOfColumns( homalg_field, "Field" );;
gap> precompile_CategoryOfColumns( commutative_homalg_ring, "CommutativeRing" );;
gap> precompile_CategoryOfColumns( EQQxy, "HomalgExteriorRingOverField" );;
gap> precompile_CategoryOfColumns( homalg_ring, "ArbitraryRing" );;
true
true
true
true

gap> LoadPackage( "FreydCategoriesForCAP", false );
true
true
gap> homalg_field := DummyHomalgField( );;
gap> commutative_homalg_ring := DummyCommutativeHomalgRing( );;
gap> homalg_ring := DummyHomalgRing( );;
gap> QQ := HomalgFieldOfRationalsInSingular( );;
gap> QQxy := QQ * "x,y";;
gap> EQQxy := KoszulDualRing( QQxy );;
gap> precompile_CategoryOfRows := function( homalg_ring, name )
>
>     CapJitPrecompileCategoryAndCompareResult(
>         homalg_ring -> CategoryOfRows(
>             homalg_ring
>         ),
>         [ homalg_ring ],
>         "FreydCategoriesForCAP",
>         Concatenation(
>             name,
>             "_precompiled"
>         ) :
>         operations := "primitive",
>         number_of_objectified_objects_in_data_structure_of_object := 1,
>         number_of_objectified_morphisms_in_data_structure_of_object := 0,
>         number_of_objectified_objects_in_data_structure_of_morphism := 2,
>         number_of_objectified_morphisms_in_data_structure_of_morphism := 1
>     ); end;;
gap> precompile_CategoryOfRows( homalg_field, "Field" );;
gap> precompile_CategoryOfRows( commutative_homalg_ring, "CommutativeRing" );;
gap> precompile_CategoryOfRows( EQQxy, "HomalgExteriorRingOverField" );;
gap> precompile_CategoryOfRows( homalg_ring, "ArbitraryRing" );;
true
true
true
true

gap> LoadPackage( "FreydCategoriesForCAP", false );
true
gap> dummy := DummyCategory( rec(
>     list_of_operations_to_install := [
>         # general category
>         "PreCompose",
>         "IdentityMorphism",
>         "IsEqualForMorphisms",
>         "IsEqualForMorphismsOnMor",
>         "IsWellDefinedForMorphisms",
>
>         # computable
>         "IsCongruentForMorphisms",
>
>         "SubtractionForMorphisms",
>         "ZeroMorphism",
>
>         # with zero object
>         "ZeroObject",
>         "UniversalMorphismIntoZeroObject",
>         "UniversalMorphismFromZeroObject",
>         "ZeroObjectFunctorial",
>
>         "DirectSum",
>         "DirectSumFunctorial",
>         "ProjectionInFactorOfDirectSum",
>         "UniversalMorphismIntoDirectSum",
>         "InjectionOfCofactorOfDirectSum",
>         "UniversalMorphismFromDirectSum",
>
>         # colifts
>         "IsColiftable"
>     ],
>     properties := [
>     ],
> ) );;
gap> StopCompilationAtPrimitivelyInstalledOperationsOfCategory( dummy );
gap> CapJitPrecompileCategoryAndCompareResult(
>     underlying_category -> CoFreydCategory_as_Opposite_FreydCategory_Opposite(
>         underlying_category
>     ),
>     [ dummy ],
>     "FreydCategoriesForCAP",
>     "CoFreydCategory_as_Opposite_FreydCategory_Opposite_precompiled" :
>     operations := "primitive",
>     number_of_objectified_objects_in_data_structure_of_object := 1,
>     number_of_objectified_morphisms_in_data_structure_of_object := 0,
>     number_of_objectified_objects_in_data_structure_of_morphism := 2,
>     number_of_objectified_morphisms_in_data_structure_of_morphism := 1
> );
true

gap> LoadPackage( "ModulePresentationsForCAP", false );
true
true
true
gap> homalg_field := DummyHomalgField( );;
gap> commutative_homalg_ring := DummyCommutativeHomalgRing( );;
gap> homalg_ring := DummyHomalgRing( );;
gap> # CAUTION: when adding new operations make sure that they are compatible
> # with the ones added manually in ADD_FUNCTIONS_FOR_LEFT/RIGHT_PRESENTATION.
> operations_for_arbitrary_ring := [
>     "CokernelColiftWithGivenCokernelObject",
>     "CokernelProjection",
>     "DirectSum",
>     "EpimorphismFromSomeProjectiveObject",
>     "IdentityMorphism",
>     "InjectionOfCofactorOfDirectSumWithGivenDirectSum",
>     "IsCongruentForMorphisms",
>     "IsEqualForMorphisms",
>     "IsEqualForObjects",
>     #"IsWellDefinedForMorphisms",
>     #"IsWellDefinedForObjects",
>     "IsZeroForMorphisms",
>     #"KernelEmbedding",
>     #"LiftAlongMonomorphism",
>     "PreCompose",
>     "ProjectionInFactorOfDirectSumWithGivenDirectSum",
>     "UniversalMorphismFromDirectSumWithGivenDirectSum",
>     "UniversalMorphismFromZeroObjectWithGivenZeroObject",
>     "UniversalMorphismIntoDirectSumWithGivenDirectSum",
>     "UniversalMorphismIntoZeroObjectWithGivenZeroObject",
>     "ZeroMorphism",
>     "ZeroObject",
> ];;
gap> operations_for_commutative_ring := Concatenation(
>     operations_for_arbitrary_ring,
>     [ #"AssociatorLeftToRightWithGivenTensorProducts",
>       #"AssociatorRightToLeftWithGivenTensorProducts",
>       #"BraidingWithGivenTensorProducts",
>       #"CoevaluationMorphismWithGivenRange",
>       #"Colift",
>       #"EvaluationMorphismWithGivenSource",
>       #"InternalHomOnMorphismsWithGivenInternalHoms",
>       #"InternalHomOnObjects",
>       #"IsColiftable",
>       #"IsLiftable",
>       #"LeftUnitorWithGivenTensorProduct",
>       #"Lift",
>       "MultiplyWithElementOfCommutativeRingForMorphisms",
>       #"RightUnitorWithGivenTensorProduct",
>       #"TensorProductOnMorphismsWithGivenTensorProducts",
>       #"TensorProductOnObjects",
>       #"TensorUnit",
>     ]
> );;
gap> precompile_LeftPresentations := function( ring, name, operations )
>
>     CapJitPrecompileCategoryAndCompareResult(
>         ring -> LeftPresentations_as_FreydCategory_CategoryOfRows( ring ),
>         [ ring ],
>         "ModulePresentationsForCAP",
>         Concatenation(
>             "LeftPresentations_as_FreydCategory_CategoryOfRows_",
>             name,
>             "_precompiled"
>         ) :
>         operations := operations
>     ); end;;
gap> precompile_LeftPresentations(
>     homalg_field, "Field", operations_for_commutative_ring
> );;
gap> precompile_LeftPresentations(
>     commutative_homalg_ring, "CommutativeRing", operations_for_commutative_ring
> );;
gap> precompile_LeftPresentations(
>     homalg_ring, "ArbitraryRing", operations_for_arbitrary_ring
> );;
gap> precompile_RightPresentations := function( ring, name, operations )
>
>     CapJitPrecompileCategoryAndCompareResult(
>         ring -> RightPresentations_as_FreydCategory_CategoryOfColumns( ring ),
>         [ ring ],
>         "ModulePresentationsForCAP",
>         Concatenation(
>             "RightPresentations_as_FreydCategory_CategoryOfColumns_",
>             name,
>             "_precompiled"
>         ) :
>         operations := operations,
>         number_of_objectified_objects_in_data_structure_of_object := 1,
>         number_of_objectified_morphisms_in_data_structure_of_object := 0,
>         number_of_objectified_objects_in_data_structure_of_morphism := 2,
>         number_of_objectified_morphisms_in_data_structure_of_morphism := 1
>     ); end;;
gap> precompile_RightPresentations(
>     homalg_field, "Field", operations_for_commutative_ring
> );;
gap> precompile_RightPresentations(
>     commutative_homalg_ring, "CommutativeRing", operations_for_commutative_ring
> );;
gap> precompile_RightPresentations(
>     homalg_ring, "ArbitraryRing", operations_for_arbitrary_ring
> );;
true
true
true
true
true
true
gap> # put the letter 'V' here to work around
> # https://github.com/frankluebeck/GAPDoc/pull/61
>

gap> LoadPackage( "LinearAlgebraForCAP", false );
true
true
gap> CAP_INTERNAL_DUMMY_HOMALG_FIELD_COUNTER := 1;;
gap> homalg_field := DummyHomalgField( );;
gap> category_constructor := function( field )
>     return Opposite(
>         MatrixCategory(
>             field :
>             no_precompiled_code := false, FinalizeCategory := true
>         ) :
>         only_primitive_operations := true
>     ); end;;
gap> given_arguments := [ homalg_field ];;
gap> compiled_category_name := "Opposite_MatrixCategory_precompiled";;
gap> package_name := "LinearAlgebraForCAP";;
gap> CapJitPrecompileCategoryAndCompareResult(
>     category_constructor,
>     given_arguments,
>     package_name,
>     compiled_category_name :
>     operations := "primitive",
>     number_of_objectified_objects_in_data_structure_of_object := 2,
>     number_of_objectified_morphisms_in_data_structure_of_object := 0,
>     number_of_objectified_objects_in_data_structure_of_morphism := 6,
>     number_of_objectified_morphisms_in_data_structure_of_morphism := 2
> );;