Goto Chapter: Top 1 2 3 Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

3 Examples and tests
 3.1 Examples
 3.2 Tests

3 Examples and tests

3.1 Examples

gap> LoadPackage( "FreydCategoriesForCAP", false );
true
gap> LoadPackage( "LinearAlgebraForCAP", false );
true
gap> Q := HomalgFieldOfRationals();;
gap> vec := MatrixCategoryAsCategoryOfRows( 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(
>     vec!.added_functions.MorphismBetweenDirectSumsWithGivenDirectSums[1][1],
>     "\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!.added_functions.MorphismBetweenDirectSumsWithGivenDirectSums[1][1],
>     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
gap> LoadPackage( "LinearAlgebraForCAP", false );
true
gap> ReadPackage( "LinearAlgebraForCAP", "gap/CompilerLogic.gi" );
true
gap> QQ := HomalgFieldOfRationalsInSingular( );;
gap> category_constructor := field -> MatrixCategoryAsCategoryOfRows( field );;
gap> given_arguments := [ QQ ];;
gap> compiled_category_name := "MatrixCategoryPrecompiled";;
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> MatrixCategoryPrecompiled( QQ );
Category of matrices over Q
gap> MatrixCategory( QQ )!.precompiled_functions_added;
true

3.2 Tests

gap> LoadPackage( "FreydCategoriesForCAP", false );
true
gap> ReadPackage( "FreydCategoriesForCAP",
>     "gap/CategoryOfRowsAsAdditiveClosureOfRingAsCategory_CompilerLogic.gi");
true
gap> QQ := HomalgFieldOfRationalsInSingular( );;
gap> QQxy := QQ * "x,y";;
gap> EQQxy := KoszulDualRing( QQxy );;
gap> R := KoszulDualRing( HomalgRingOfIntegersInSingular( ) * "x,y" );;
gap> precompile_CategoryOfColumns := function( homalg_ring, name )
>     
>     CapJitPrecompileCategoryAndCompareResult(
>         homalg_ring -> CategoryOfColumns(
>             homalg_ring
>         ),
>         [ homalg_ring ],
>         "FreydCategoriesForCAP",
>         Concatenation(
>             "CategoryOfColumnsAsOppositeOfCategoryOfRowsOf",
>             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( QQ, "Field" );;
gap> precompile_CategoryOfColumns( QQxy, "CommutativeRing" );;
gap> precompile_CategoryOfColumns( EQQxy, "HomalgExteriorRingOverField" );;
gap> precompile_CategoryOfColumns( R, "ArbitraryRing" );;
gap> CategoryOfColumns( QQ )!.precompiled_functions_added;
true
gap> CategoryOfColumns( QQxy )!.precompiled_functions_added;
true
gap> CategoryOfColumns( EQQxy )!.precompiled_functions_added;
true
gap> CategoryOfColumns( R )!.precompiled_functions_added;
true
gap> LoadPackage( "FreydCategoriesForCAP", false );
true
gap> ReadPackage( "FreydCategoriesForCAP",
>     "gap/CategoryOfRowsAsAdditiveClosureOfRingAsCategory_CompilerLogic.gi");
true
gap> QQ := HomalgFieldOfRationalsInSingular( );;
gap> QQxy := QQ * "x,y";;
gap> EQQxy := KoszulDualRing( QQxy );;
gap> R := KoszulDualRing( HomalgRingOfIntegersInSingular( ) * "x,y" );;
gap> precompile_CategoryOfRows := function( homalg_ring, name )
>     
>     CapJitPrecompileCategoryAndCompareResult(
>         homalg_ring -> CategoryOfRows(
>             homalg_ring
>         ),
>         [ homalg_ring ],
>         "FreydCategoriesForCAP",
>         Concatenation(
>             "CategoryOfRowsAsAdditiveClosureOfRingAsCategoryOf",
>             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( QQ, "Field" );;
gap> precompile_CategoryOfRows( QQxy, "CommutativeRing" );;
gap> precompile_CategoryOfRows( EQQxy, "HomalgExteriorRingOverField" );;
gap> precompile_CategoryOfRows( R, "ArbitraryRing" );;
gap> CategoryOfRows( QQ )!.precompiled_functions_added;
true
gap> CategoryOfRows( QQxy )!.precompiled_functions_added;
true
gap> CategoryOfRows( EQQxy )!.precompiled_functions_added;
true
gap> CategoryOfRows( R )!.precompiled_functions_added;
true
gap> LoadPackage( "FreydCategoriesForCAP", false );
true
gap> dummy := DummyCategory( rec(
>     list_of_operations_to_install := [
>         # general category
>         "PreCompose",
>         "IdentityMorphism",
>         "IsEqualForMorphisms",
>         "IsEqualForMorphismsOnMor",
>         "IsWellDefinedForMorphisms",
>         
>         # computable
>         "IsCongruentForMorphisms",
>         
>         # pre-additive
>         "AdditionForMorphisms",
>         "SubtractionForMorphisms",
>         "AdditiveInverseForMorphisms",
>         "ZeroMorphism",
>         
>         # with zero object
>         "ZeroObject",
>         "UniversalMorphismIntoZeroObject",
>         "UniversalMorphismFromZeroObject",
>         "ZeroObjectFunctorial",
>         
>         # additive
>         "DirectSum",
>         "DirectSumFunctorial",
>         "ProjectionInFactorOfDirectSum",
>         "UniversalMorphismIntoDirectSum",
>         "InjectionOfCofactorOfDirectSum",
>         "UniversalMorphismFromDirectSum",
>         
>         # colifts
>         "IsColiftable"
>     ],
>     properties := [
>         "IsAdditiveCategory",
>     ],
> ) );;
gap> StopCompilationAtPrimitivelyInstalledOperationsOfCategory( dummy );
gap> CapJitPrecompileCategoryAndCompareResult(
>     underlying_category -> CoFreydCategoryAsOppositeOfFreydCategoryOfOpposite(
>         underlying_category
>     ),
>     [ dummy ],
>     "FreydCategoriesForCAP",
>     "CoFreydCategoryAsOppositeOfFreydCategoryOfOppositePrecompiled" :
>     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
> );
gap> CoFreydCategory( dummy )!.precompiled_functions_added;
true
gap> LoadPackage( "ModulePresentationsForCAP", false );
true
gap> ReadPackage( "LinearAlgebraForCAP", "gap/CompilerLogic.gi" );
true
gap> QQ := HomalgFieldOfRationalsInSingular( );;
gap> QQxy := QQ * "x,y";;
gap> EEE := KoszulDualRing( QQxy * "a,b" );;
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 := [
>     "AdditionForMorphisms",
>     "AdditiveInverseForMorphisms",
>     "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",
>       #"ColiftOrFail",
>       #"EvaluationMorphismWithGivenSource",
>       #"InternalHomOnMorphismsWithGivenInternalHoms",
>       #"InternalHomOnObjects",
>       #"IsColiftable",
>       #"IsLiftable",
>       #"LeftUnitorWithGivenTensorProduct",
>       #"Lift",
>       #"LiftOrFail",
>       "MultiplyWithElementOfCommutativeRingForMorphisms",
>       #"RightUnitorWithGivenTensorProduct",
>       #"TensorProductOnMorphismsWithGivenTensorProducts",
>       #"TensorProductOnObjects",
>       #"TensorUnit",
>     ]
> );;
gap> precompile_LeftPresentations := function( ring, name, operations )
>     
>     CapJitPrecompileCategoryAndCompareResult(
>         ring -> LeftPresentationsAsFreydCategoryOfCategoryOfRows( ring ),
>         [ ring ],
>         "ModulePresentationsForCAP",
>         Concatenation(
>             "LeftPresentationsAsFreydCategoryOfCategoryOfRowsOf",
>             name,
>             "Precompiled"
>         ) :
>         operations := operations
>     ); end;;
gap> precompile_LeftPresentations(
>     QQ, "Field", operations_for_commutative_ring
> );;
gap> precompile_LeftPresentations(
>     QQxy, "CommutativeRing", operations_for_commutative_ring
> );;
gap> precompile_LeftPresentations(
>     EEE, "ArbitraryRing", operations_for_arbitrary_ring
> );;
gap> precompile_RightPresentations := function( ring, name, operations )
>     
>     CapJitPrecompileCategoryAndCompareResult(
>         ring -> RightPresentationsAsFreydCategoryOfCategoryOfColumns( ring ),
>         [ ring ],
>         "ModulePresentationsForCAP",
>         Concatenation(
>             "RightPresentationsAsFreydCategoryOfCategoryOfColumnsOf",
>             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(
>     QQ, "Field", operations_for_commutative_ring
> );;
gap> precompile_RightPresentations(
>     QQxy, "CommutativeRing", operations_for_commutative_ring
> );;
gap> precompile_RightPresentations(
>     EEE, "ArbitraryRing", operations_for_arbitrary_ring
> );;
gap> LeftPresentations( QQ )!.precompiled_functions_added;
true
gap> LeftPresentations( QQxy )!.precompiled_functions_added;
true
gap> LeftPresentations( EEE )!.precompiled_functions_added;
true
gap> RightPresentations( QQ )!.precompiled_functions_added;
true
gap> RightPresentations( QQxy )!.precompiled_functions_added;
true
gap> RightPresentations( EEE )!.precompiled_functions_added;
true
gap> # put the letter 'V' here to work around
> # https://github.com/frankluebeck/GAPDoc/pull/61
> 
gap> LoadPackage( "LinearAlgebraForCAP", false );
true
gap> QQ := HomalgFieldOfRationalsInSingular( );;
gap> # be careful not to use `MatrixCategory` because attributes are not supported
> category_constructor := function( field )
>     return Opposite(
>         MATRIX_CATEGORY(
>             field :
>             no_precompiled_code := false, FinalizeCategory := true
>         ) :
>         only_primitive_operations := true
>     ); end;;
gap> given_arguments := [ QQ ];;
gap> compiled_category_name := "OppositeOfMatrixCategoryPrecompiled";;
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
> );;
gap> ReadPackage(
>     "LinearAlgebraForCAP",
>     "gap/precompiled_categories/OppositeOfMatrixCategoryPrecompiled.gi"
> );;
gap> OppositeOfMatrixCategoryPrecompiled( QQ );
Opposite( Category of matrices over Q )
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 Ind

generated by GAPDoc2HTML