From 2ca9169733d275aa6e578e1b715e00c7a4e9bd00 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Sun, 16 May 2021 14:38:53 +0200 Subject: [PATCH 1/6] Replace number_of_diagram_arguments by object_arguments_positions --- CompilerForCAP/gap/PrecompileCategory.gi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CompilerForCAP/gap/PrecompileCategory.gi b/CompilerForCAP/gap/PrecompileCategory.gi index a0a7d610a4..b4a921e02f 100644 --- a/CompilerForCAP/gap/PrecompileCategory.gi +++ b/CompilerForCAP/gap/PrecompileCategory.gi @@ -389,7 +389,7 @@ InstallGlobalFunction( "CapJitPrecompileCategory", function ( category_construct if CanCompute( cat, object_name ) then - example_input[Length( example_input )] := CallFuncList( ValueGlobal( object_name ), example_input{[ 1 .. current_rec.number_of_diagram_arguments + 1 ]} ); + example_input[Length( example_input )] := CallFuncList( ValueGlobal( object_name ), example_input{CAP_INTERNAL_METHOD_NAME_RECORD.(current_rec.with_given_without_given_name_pair[1]).object_arguments_positions} ); else From 89bb5494dc3acf1cd2a452a3cf56002083c82025 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Sun, 16 May 2021 14:39:25 +0200 Subject: [PATCH 2/6] Make precompiled output easier to read --- CompilerForCAP/gap/PrecompileCategory.gi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CompilerForCAP/gap/PrecompileCategory.gi b/CompilerForCAP/gap/PrecompileCategory.gi index b4a921e02f..566768cc3a 100644 --- a/CompilerForCAP/gap/PrecompileCategory.gi +++ b/CompilerForCAP/gap/PrecompileCategory.gi @@ -426,9 +426,9 @@ InstallGlobalFunction( "CapJitPrecompileCategory", function ( category_construct " ##\n", " Add", function_name, "( cat,\n", " \n", - " \n", - " ", function_string, "\n", - " \n", + "########\n", + function_string, "\n", + "########\n", " \n", " );\n" ); From ff8db913767d03ec7525c198d2ff26dbd9874367 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Sun, 16 May 2021 14:39:47 +0200 Subject: [PATCH 3/6] Make safe operations available to outside code --- CompilerForCAP/gap/PrecompileCategory.gi | 482 +++++++++++------------ 1 file changed, 241 insertions(+), 241 deletions(-) diff --git a/CompilerForCAP/gap/PrecompileCategory.gi b/CompilerForCAP/gap/PrecompileCategory.gi index 566768cc3a..96ecf49705 100644 --- a/CompilerForCAP/gap/PrecompileCategory.gi +++ b/CompilerForCAP/gap/PrecompileCategory.gi @@ -3,8 +3,246 @@ # # Implementations # +# operations for which our example input constructed below is a valid input +BindGlobal( "CAP_JIT_INTERNAL_SAFE_OPERATIONS", [ + "AdditionForMorphisms", + "AdditiveInverseForMorphisms", + "AstrictionToCoimage", + "AstrictionToCoimageWithGivenCoimage", + "BasisOfExternalHom", + "CanonicalIdentificationFromCoimageToImageObject", + "CanonicalIdentificationFromImageObjectToCoimage", + "CoastrictionToImage", + "CoastrictionToImageWithGivenImageObject", + #"CoefficientsOfMorphismWithGivenBasisOfExternalHom", + "Coequalizer", + #"CoequalizerFunctorialWithGivenCoequalizers", + "Coimage", + "CoimageProjection", + "CoimageProjectionWithGivenCoimage", + "CokernelColift", + "CokernelColiftWithGivenCokernelObject", + "CokernelObject", + #"CokernelObjectFunctorialWithGivenCokernelObjects", + "CokernelProjection", + "CokernelProjectionWithGivenCokernelObject", + "Colift", + "ColiftAlongEpimorphism", + #"ComponentOfMorphismFromDirectSum", + #"ComponentOfMorphismIntoDirectSum", + "Coproduct", + #"CoproductFunctorialWithGivenCoproducts", + "DirectProduct", + #"DirectProductFunctorialWithGivenDirectProducts", + "DirectSum", + "DirectSumCodiagonalDifference", + "DirectSumDiagonalDifference", + #"DirectSumFunctorialWithGivenDirectSums", + "DirectSumProjectionInPushout", + "DistinguishedObjectOfHomomorphismStructure", + "EmbeddingOfEqualizer", + "EmbeddingOfEqualizerWithGivenEqualizer", + "EpimorphismFromSomeProjectiveObject", + "EpimorphismFromSomeProjectiveObjectWithGivenSomeProjectiveObject", + "Equalizer", + #"EqualizerFunctorialWithGivenEqualizers", + "FiberProduct", + "FiberProductEmbeddingInDirectSum", + #"FiberProductFunctorialWithGivenFiberProducts", + "HomologyObject", + #"HomologyObjectFunctorialWithGivenHomologyObjects", + #"HomomorphismStructureOnMorphismsWithGivenObjects", + "HomomorphismStructureOnObjects", + #"HorizontalPostCompose", + #"HorizontalPreCompose", + "IdentityMorphism", + #"IdentityTwoCell", + "ImageEmbedding", + "ImageEmbeddingWithGivenImageObject", + "ImageObject", + "InitialObject", + "InitialObjectFunctorial", + "InjectionOfCofactorOfCoproduct", + "InjectionOfCofactorOfCoproductWithGivenCoproduct", + "InjectionOfCofactorOfDirectSum", + "InjectionOfCofactorOfDirectSumWithGivenDirectSum", + "InjectionOfCofactorOfPushout", + "InjectionOfCofactorOfPushoutWithGivenPushout", + "InjectiveColift", + "InterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure", + #"InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism", + "InverseForMorphisms", + #"InverseMorphismFromCoimageToImageWithGivenObjects", + "IsAutomorphism", + #"IsCodominating", + "IsColiftable", + "IsColiftableAlongEpimorphism", + "IsCongruentForMorphisms", + #"IsDominating", + "IsEndomorphism", + "IsEpimorphism", + #"IsEqualAsFactorobjects", + #"IsEqualAsSubobjects", + "IsEqualForCacheForMorphisms", + "IsEqualForCacheForObjects", + "IsEqualForMorphisms", + "IsEqualForMorphismsOnMor", + "IsEqualForObjects", + "IsHomSetInhabited", + "IsIdempotent", + "IsIdenticalToIdentityMorphism", + "IsIdenticalToZeroMorphism", + "IsInitial", + "IsInjective", + "IsIsomorphism", + "IsLiftable", + "IsLiftableAlongMonomorphism", + "IsMonomorphism", + "IsOne", + "IsProjective", + "IsSplitEpimorphism", + "IsSplitMonomorphism", + "IsTerminal", + "IsWellDefinedForMorphisms", + "IsWellDefinedForObjects", + #"IsWellDefinedForTwoCells", + "IsZeroForMorphisms", + "IsZeroForObjects", + "IsomorphismFromCoequalizerOfCoproductDiagramToPushout", + "IsomorphismFromCoimageToCokernelOfKernel", + "IsomorphismFromCokernelOfDiagonalDifferenceToPushout", + "IsomorphismFromCokernelOfKernelToCoimage", + "IsomorphismFromCoproductToDirectSum", + "IsomorphismFromDirectProductToDirectSum", + "IsomorphismFromDirectSumToCoproduct", + "IsomorphismFromDirectSumToDirectProduct", + "IsomorphismFromEqualizerOfDirectProductDiagramToFiberProduct", + "IsomorphismFromFiberProductToEqualizerOfDirectProductDiagram", + "IsomorphismFromFiberProductToKernelOfDiagonalDifference", + "IsomorphismFromHomologyObjectToItsConstructionAsAnImageObject", + "IsomorphismFromImageObjectToKernelOfCokernel", + "IsomorphismFromInitialObjectToZeroObject", + "IsomorphismFromItsConstructionAsAnImageObjectToHomologyObject", + "IsomorphismFromKernelOfCokernelToImageObject", + "IsomorphismFromKernelOfDiagonalDifferenceToFiberProduct", + "IsomorphismFromPushoutToCoequalizerOfCoproductDiagram", + "IsomorphismFromPushoutToCokernelOfDiagonalDifference", + "IsomorphismFromTerminalObjectToZeroObject", + "IsomorphismFromZeroObjectToInitialObject", + "IsomorphismFromZeroObjectToTerminalObject", + "KernelEmbedding", + "KernelEmbeddingWithGivenKernelObject", + "KernelLift", + "KernelLiftWithGivenKernelObject", + "KernelObject", + #"KernelObjectFunctorialWithGivenKernelObjects", + "Lift", + "LiftAlongMonomorphism", + #"MereExistenceOfSolutionOfLinearSystemInAbCategory", + "MonomorphismIntoSomeInjectiveObject", + "MonomorphismIntoSomeInjectiveObjectWithGivenSomeInjectiveObject", + #"MorphismBetweenDirectSumsWithGivenDirectSums", + #"MorphismFromCoimageToImageWithGivenObjects", + "MorphismFromEqualizerToSink", + "MorphismFromEqualizerToSinkWithGivenEqualizer", + "MorphismFromFiberProductToSink", + "MorphismFromFiberProductToSinkWithGivenFiberProduct", + "MorphismFromKernelObjectToSink", + "MorphismFromKernelObjectToSinkWithGivenKernelObject", + "MorphismFromSourceToCoequalizer", + "MorphismFromSourceToCoequalizerWithGivenCoequalizer", + "MorphismFromSourceToCokernelObject", + "MorphismFromSourceToCokernelObjectWithGivenCokernelObject", + "MorphismFromSourceToPushout", + "MorphismFromSourceToPushoutWithGivenPushout", + #"MultiplyWithElementOfCommutativeRingForMorphisms", + "PostCompose", + "PreCompose", + "ProjectionInFactorOfDirectProduct", + "ProjectionInFactorOfDirectProductWithGivenDirectProduct", + "ProjectionInFactorOfDirectSum", + "ProjectionInFactorOfDirectSumWithGivenDirectSum", + "ProjectionInFactorOfFiberProduct", + "ProjectionInFactorOfFiberProductWithGivenFiberProduct", + "ProjectionOntoCoequalizer", + "ProjectionOntoCoequalizerWithGivenCoequalizer", + "ProjectiveLift", + "Pushout", + #"PushoutFunctorialWithGivenPushouts", + #"RandomMorphismByInteger", + #"RandomMorphismByList", + #"RandomMorphismWithFixedRangeByInteger", + #"RandomMorphismWithFixedRangeByList", + #"RandomMorphismWithFixedSourceAndRangeByInteger", + #"RandomMorphismWithFixedSourceAndRangeByList", + #"RandomMorphismWithFixedSourceByInteger", + #"RandomMorphismWithFixedSourceByList", + #"RandomObjectByInteger", + #"RandomObjectByList", + #"SimplifyEndo", + #"SimplifyEndo_IsoFromInputObject", + #"SimplifyEndo_IsoToInputObject", + #"SimplifyMorphism", + #"SimplifyObject", + #"SimplifyObject_IsoFromInputObject", + #"SimplifyObject_IsoToInputObject", + #"SimplifyRange", + #"SimplifyRange_IsoFromInputObject", + #"SimplifyRange_IsoToInputObject", + #"SimplifySource", + #"SimplifySourceAndRange", + #"SimplifySourceAndRange_IsoFromInputRange", + #"SimplifySourceAndRange_IsoFromInputSource", + #"SimplifySourceAndRange_IsoToInputRange", + #"SimplifySourceAndRange_IsoToInputSource", + #"SimplifySource_IsoFromInputObject", + #"SimplifySource_IsoToInputObject", + #"SolveLinearSystemInAbCategory", + "SomeInjectiveObject", + "SomeProjectiveObject", + #"SomeReductionBySplitEpiSummand", + #"SomeReductionBySplitEpiSummand_MorphismFromInputRange", + #"SomeReductionBySplitEpiSummand_MorphismToInputRange", + "SubtractionForMorphisms", + "TerminalObject", + "TerminalObjectFunctorial", + "UniversalMorphismFromCoequalizer", + "UniversalMorphismFromCoequalizerWithGivenCoequalizer", + "UniversalMorphismFromCoproduct", + "UniversalMorphismFromCoproductWithGivenCoproduct", + "UniversalMorphismFromDirectSum", + "UniversalMorphismFromDirectSumWithGivenDirectSum", + #"UniversalMorphismFromImage", + #"UniversalMorphismFromImageWithGivenImageObject", + "UniversalMorphismFromInitialObject", + "UniversalMorphismFromInitialObjectWithGivenInitialObject", + "UniversalMorphismFromPushout", + "UniversalMorphismFromPushoutWithGivenPushout", + "UniversalMorphismFromZeroObject", + "UniversalMorphismFromZeroObjectWithGivenZeroObject", + #"UniversalMorphismIntoCoimage", + #"UniversalMorphismIntoCoimageWithGivenCoimage", + "UniversalMorphismIntoDirectProduct", + "UniversalMorphismIntoDirectProductWithGivenDirectProduct", + "UniversalMorphismIntoDirectSum", + "UniversalMorphismIntoDirectSumWithGivenDirectSum", + "UniversalMorphismIntoEqualizer", + "UniversalMorphismIntoEqualizerWithGivenEqualizer", + "UniversalMorphismIntoFiberProduct", + "UniversalMorphismIntoFiberProductWithGivenFiberProduct", + "UniversalMorphismIntoTerminalObject", + "UniversalMorphismIntoTerminalObjectWithGivenTerminalObject", + "UniversalMorphismIntoZeroObject", + "UniversalMorphismIntoZeroObjectWithGivenZeroObject", + #"VerticalPostCompose", + #"VerticalPreCompose", + "ZeroMorphism", + "ZeroObject", + "ZeroObjectFunctorial", +] ); + InstallGlobalFunction( "CapJitPrecompileCategory", function ( category_constructor, given_arguments, package_name, compiled_category_name ) - local cat, obj, mor, safe_operations, operations, diff, output_string, package_info, parameters_string, current_string, object_name, index, compiled_func, function_string, filter_list, example_input, function_name, current_rec; + local cat, obj, mor, operations, diff, output_string, package_info, parameters_string, current_string, object_name, index, compiled_func, function_string, filter_list, example_input, function_name, current_rec; if IsOperation( category_constructor ) or IsKernelFunction( category_constructor ) then @@ -38,247 +276,9 @@ InstallGlobalFunction( "CapJitPrecompileCategory", function ( category_construct obj := ZeroObject( cat ); mor := ZeroMorphism( obj, obj ); - # operations for which our example input constructed below is a valid input - safe_operations := [ - "AdditionForMorphisms", - "AdditiveInverseForMorphisms", - "AstrictionToCoimage", - "AstrictionToCoimageWithGivenCoimage", - "BasisOfExternalHom", - "CanonicalIdentificationFromCoimageToImageObject", - "CanonicalIdentificationFromImageObjectToCoimage", - "CoastrictionToImage", - "CoastrictionToImageWithGivenImageObject", - #"CoefficientsOfMorphismWithGivenBasisOfExternalHom", - "Coequalizer", - #"CoequalizerFunctorialWithGivenCoequalizers", - "Coimage", - "CoimageProjection", - "CoimageProjectionWithGivenCoimage", - "CokernelColift", - "CokernelColiftWithGivenCokernelObject", - "CokernelObject", - #"CokernelObjectFunctorialWithGivenCokernelObjects", - "CokernelProjection", - "CokernelProjectionWithGivenCokernelObject", - "Colift", - "ColiftAlongEpimorphism", - #"ComponentOfMorphismFromDirectSum", - #"ComponentOfMorphismIntoDirectSum", - "Coproduct", - #"CoproductFunctorialWithGivenCoproducts", - "DirectProduct", - #"DirectProductFunctorialWithGivenDirectProducts", - "DirectSum", - "DirectSumCodiagonalDifference", - "DirectSumDiagonalDifference", - #"DirectSumFunctorialWithGivenDirectSums", - "DirectSumProjectionInPushout", - "DistinguishedObjectOfHomomorphismStructure", - "EmbeddingOfEqualizer", - "EmbeddingOfEqualizerWithGivenEqualizer", - "EpimorphismFromSomeProjectiveObject", - "EpimorphismFromSomeProjectiveObjectWithGivenSomeProjectiveObject", - "Equalizer", - #"EqualizerFunctorialWithGivenEqualizers", - "FiberProduct", - "FiberProductEmbeddingInDirectSum", - #"FiberProductFunctorialWithGivenFiberProducts", - "HomologyObject", - #"HomologyObjectFunctorialWithGivenHomologyObjects", - #"HomomorphismStructureOnMorphismsWithGivenObjects", - "HomomorphismStructureOnObjects", - #"HorizontalPostCompose", - #"HorizontalPreCompose", - "IdentityMorphism", - #"IdentityTwoCell", - "ImageEmbedding", - "ImageEmbeddingWithGivenImageObject", - "ImageObject", - "InitialObject", - "InitialObjectFunctorial", - "InjectionOfCofactorOfCoproduct", - "InjectionOfCofactorOfCoproductWithGivenCoproduct", - "InjectionOfCofactorOfDirectSum", - "InjectionOfCofactorOfDirectSumWithGivenDirectSum", - "InjectionOfCofactorOfPushout", - "InjectionOfCofactorOfPushoutWithGivenPushout", - "InjectiveColift", - "InterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure", - #"InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism", - "InverseForMorphisms", - #"InverseMorphismFromCoimageToImageWithGivenObjects", - "IsAutomorphism", - #"IsCodominating", - "IsColiftable", - "IsColiftableAlongEpimorphism", - "IsCongruentForMorphisms", - #"IsDominating", - "IsEndomorphism", - "IsEpimorphism", - #"IsEqualAsFactorobjects", - #"IsEqualAsSubobjects", - "IsEqualForCacheForMorphisms", - "IsEqualForCacheForObjects", - "IsEqualForMorphisms", - "IsEqualForMorphismsOnMor", - "IsEqualForObjects", - "IsHomSetInhabited", - "IsIdempotent", - "IsIdenticalToIdentityMorphism", - "IsIdenticalToZeroMorphism", - "IsInitial", - "IsInjective", - "IsIsomorphism", - "IsLiftable", - "IsLiftableAlongMonomorphism", - "IsMonomorphism", - "IsOne", - "IsProjective", - "IsSplitEpimorphism", - "IsSplitMonomorphism", - "IsTerminal", - "IsWellDefinedForMorphisms", - "IsWellDefinedForObjects", - #"IsWellDefinedForTwoCells", - "IsZeroForMorphisms", - "IsZeroForObjects", - "IsomorphismFromCoequalizerOfCoproductDiagramToPushout", - "IsomorphismFromCoimageToCokernelOfKernel", - "IsomorphismFromCokernelOfDiagonalDifferenceToPushout", - "IsomorphismFromCokernelOfKernelToCoimage", - "IsomorphismFromCoproductToDirectSum", - "IsomorphismFromDirectProductToDirectSum", - "IsomorphismFromDirectSumToCoproduct", - "IsomorphismFromDirectSumToDirectProduct", - "IsomorphismFromEqualizerOfDirectProductDiagramToFiberProduct", - "IsomorphismFromFiberProductToEqualizerOfDirectProductDiagram", - "IsomorphismFromFiberProductToKernelOfDiagonalDifference", - "IsomorphismFromHomologyObjectToItsConstructionAsAnImageObject", - "IsomorphismFromImageObjectToKernelOfCokernel", - "IsomorphismFromInitialObjectToZeroObject", - "IsomorphismFromItsConstructionAsAnImageObjectToHomologyObject", - "IsomorphismFromKernelOfCokernelToImageObject", - "IsomorphismFromKernelOfDiagonalDifferenceToFiberProduct", - "IsomorphismFromPushoutToCoequalizerOfCoproductDiagram", - "IsomorphismFromPushoutToCokernelOfDiagonalDifference", - "IsomorphismFromTerminalObjectToZeroObject", - "IsomorphismFromZeroObjectToInitialObject", - "IsomorphismFromZeroObjectToTerminalObject", - "KernelEmbedding", - "KernelEmbeddingWithGivenKernelObject", - "KernelLift", - "KernelLiftWithGivenKernelObject", - "KernelObject", - #"KernelObjectFunctorialWithGivenKernelObjects", - "Lift", - "LiftAlongMonomorphism", - #"MereExistenceOfSolutionOfLinearSystemInAbCategory", - "MonomorphismIntoSomeInjectiveObject", - "MonomorphismIntoSomeInjectiveObjectWithGivenSomeInjectiveObject", - #"MorphismBetweenDirectSumsWithGivenDirectSums", - #"MorphismFromCoimageToImageWithGivenObjects", - "MorphismFromEqualizerToSink", - "MorphismFromEqualizerToSinkWithGivenEqualizer", - "MorphismFromFiberProductToSink", - "MorphismFromFiberProductToSinkWithGivenFiberProduct", - "MorphismFromKernelObjectToSink", - "MorphismFromKernelObjectToSinkWithGivenKernelObject", - "MorphismFromSourceToCoequalizer", - "MorphismFromSourceToCoequalizerWithGivenCoequalizer", - "MorphismFromSourceToCokernelObject", - "MorphismFromSourceToCokernelObjectWithGivenCokernelObject", - "MorphismFromSourceToPushout", - "MorphismFromSourceToPushoutWithGivenPushout", - #"MultiplyWithElementOfCommutativeRingForMorphisms", - "PostCompose", - "PreCompose", - "ProjectionInFactorOfDirectProduct", - "ProjectionInFactorOfDirectProductWithGivenDirectProduct", - "ProjectionInFactorOfDirectSum", - "ProjectionInFactorOfDirectSumWithGivenDirectSum", - "ProjectionInFactorOfFiberProduct", - "ProjectionInFactorOfFiberProductWithGivenFiberProduct", - "ProjectionOntoCoequalizer", - "ProjectionOntoCoequalizerWithGivenCoequalizer", - "ProjectiveLift", - "Pushout", - #"PushoutFunctorialWithGivenPushouts", - #"RandomMorphismByInteger", - #"RandomMorphismByList", - #"RandomMorphismWithFixedRangeByInteger", - #"RandomMorphismWithFixedRangeByList", - #"RandomMorphismWithFixedSourceAndRangeByInteger", - #"RandomMorphismWithFixedSourceAndRangeByList", - #"RandomMorphismWithFixedSourceByInteger", - #"RandomMorphismWithFixedSourceByList", - #"RandomObjectByInteger", - #"RandomObjectByList", - #"SimplifyEndo", - #"SimplifyEndo_IsoFromInputObject", - #"SimplifyEndo_IsoToInputObject", - #"SimplifyMorphism", - #"SimplifyObject", - #"SimplifyObject_IsoFromInputObject", - #"SimplifyObject_IsoToInputObject", - #"SimplifyRange", - #"SimplifyRange_IsoFromInputObject", - #"SimplifyRange_IsoToInputObject", - #"SimplifySource", - #"SimplifySourceAndRange", - #"SimplifySourceAndRange_IsoFromInputRange", - #"SimplifySourceAndRange_IsoFromInputSource", - #"SimplifySourceAndRange_IsoToInputRange", - #"SimplifySourceAndRange_IsoToInputSource", - #"SimplifySource_IsoFromInputObject", - #"SimplifySource_IsoToInputObject", - #"SolveLinearSystemInAbCategory", - "SomeInjectiveObject", - "SomeProjectiveObject", - #"SomeReductionBySplitEpiSummand", - #"SomeReductionBySplitEpiSummand_MorphismFromInputRange", - #"SomeReductionBySplitEpiSummand_MorphismToInputRange", - "SubtractionForMorphisms", - "TerminalObject", - "TerminalObjectFunctorial", - "UniversalMorphismFromCoequalizer", - "UniversalMorphismFromCoequalizerWithGivenCoequalizer", - "UniversalMorphismFromCoproduct", - "UniversalMorphismFromCoproductWithGivenCoproduct", - "UniversalMorphismFromDirectSum", - "UniversalMorphismFromDirectSumWithGivenDirectSum", - #"UniversalMorphismFromImage", - #"UniversalMorphismFromImageWithGivenImageObject", - "UniversalMorphismFromInitialObject", - "UniversalMorphismFromInitialObjectWithGivenInitialObject", - "UniversalMorphismFromPushout", - "UniversalMorphismFromPushoutWithGivenPushout", - "UniversalMorphismFromZeroObject", - "UniversalMorphismFromZeroObjectWithGivenZeroObject", - #"UniversalMorphismIntoCoimage", - #"UniversalMorphismIntoCoimageWithGivenCoimage", - "UniversalMorphismIntoDirectProduct", - "UniversalMorphismIntoDirectProductWithGivenDirectProduct", - "UniversalMorphismIntoDirectSum", - "UniversalMorphismIntoDirectSumWithGivenDirectSum", - "UniversalMorphismIntoEqualizer", - "UniversalMorphismIntoEqualizerWithGivenEqualizer", - "UniversalMorphismIntoFiberProduct", - "UniversalMorphismIntoFiberProductWithGivenFiberProduct", - "UniversalMorphismIntoTerminalObject", - "UniversalMorphismIntoTerminalObjectWithGivenTerminalObject", - "UniversalMorphismIntoZeroObject", - "UniversalMorphismIntoZeroObjectWithGivenZeroObject", - #"VerticalPostCompose", - #"VerticalPreCompose", - "ZeroMorphism", - "ZeroObject", - "ZeroObjectFunctorial", - ]; - if ValueOption( "operations" ) = fail then - operations := Intersection( ListInstalledOperationsOfCategory( cat ), safe_operations ); + operations := Intersection( ListInstalledOperationsOfCategory( cat ), CAP_JIT_INTERNAL_SAFE_OPERATIONS ); else @@ -286,7 +286,7 @@ InstallGlobalFunction( "CapJitPrecompileCategory", function ( category_construct fi; - diff := Difference( operations, safe_operations ); + diff := Difference( operations, CAP_JIT_INTERNAL_SAFE_OPERATIONS ); if Length( diff ) > 0 then From 5b088a1c09f4100733b522b46a8cc6e1750b13de Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Sun, 16 May 2021 14:40:29 +0200 Subject: [PATCH 4/6] Precompile more operations of LinearAlgebraForCAP --- .../examples/PrecompileLinearAlgebraForCAP.g | 33 +- .../gap/LinearAlgebraForCAP.gi | 4 +- .../MatrixCategoryPrecompiled.gi | 1052 ++++++++++++++++- 3 files changed, 1074 insertions(+), 15 deletions(-) diff --git a/CompilerForCAP/examples/PrecompileLinearAlgebraForCAP.g b/CompilerForCAP/examples/PrecompileLinearAlgebraForCAP.g index bd38f68bd4..5dadef5cb9 100644 --- a/CompilerForCAP/examples/PrecompileLinearAlgebraForCAP.g +++ b/CompilerForCAP/examples/PrecompileLinearAlgebraForCAP.g @@ -13,11 +13,34 @@ category_constructor := field -> MATRIX_CATEGORY( field );; given_arguments := [ QQ ];; compiled_category_name := "MatrixCategoryPrecompiled";; package_name := "LinearAlgebraForCAP";; -operations := [ - "AdditionForMorphisms", - "PreCompose", - "KernelEmbedding", -];; +operations := Intersection( + ListInstalledOperationsOfCategory( category_constructor( QQ ) ), + CAP_JIT_INTERNAL_SAFE_OPERATIONS +);; +# exclude some operations which currently do not yield nice results +operations := Filtered( operations, + o -> PositionSublist( o, "FiberProduct" ) = fail );; +operations := Filtered( operations, + o -> PositionSublist( o, "Pushout" ) = fail );; +operations := Filtered( operations, + o -> PositionSublist( o, "Image" ) = fail );; +operations := Filtered( operations, + o -> PositionSublist( o, "Coimage" ) = fail );; +operations := Filtered( operations, + o -> PositionSublist( o, "DirectProduct" ) = fail );; +operations := Filtered( operations, + o -> PositionSublist( o, "Coproduct" ) = fail );; +operations := Filtered( operations, + o -> PositionSublist( o, "TerminalObject" ) = fail );; +operations := Filtered( operations, + o -> PositionSublist( o, "InitialObject" ) = fail );; +operations := Difference( operations, [ "DirectSumCodiagonalDifference" ] );; +operations := Difference( operations, [ "DirectSumDiagonalDifference" ] );; +operations := Difference( operations, [ "HomologyObject" ] );; +# IsEqualForMorphismsOnMor causes problems in GAP 4.11 (see GAP issue #4449) +operations := Difference( operations, [ "IsEqualForMorphismsOnMor" ] );; +operations := Difference( operations, [ "IsIdenticalToIdentityMorphism" ] );; +operations := Difference( operations, [ "IsIdenticalToZeroMorphism" ] );; filepath := "precompiled_categories/MatrixCategoryPrecompiled.gi";; old_file_content := ReadFileFromPackageForHomalg( package_name, filepath );; diff --git a/LinearAlgebraForCAP/gap/LinearAlgebraForCAP.gi b/LinearAlgebraForCAP/gap/LinearAlgebraForCAP.gi index 7b85cc3ee2..049590fdc0 100644 --- a/LinearAlgebraForCAP/gap/LinearAlgebraForCAP.gi +++ b/LinearAlgebraForCAP/gap/LinearAlgebraForCAP.gi @@ -859,7 +859,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_MATRIX_CATEGORY, AddEpimorphismFromSomeProjectiveObject( category, { cat, obj } -> IdentityMorphism( obj ) ); ## - AddIsProjective( category, ReturnTrue ); + AddIsProjective( category, { cat, obj } -> true ); ## AddSomeInjectiveObject( category, { cat, obj } -> obj ); @@ -868,7 +868,7 @@ InstallGlobalFunction( INSTALL_FUNCTIONS_FOR_MATRIX_CATEGORY, AddMonomorphismIntoSomeInjectiveObject( category, { cat, obj } -> IdentityMorphism( obj ) ); ## - AddIsInjective( category, ReturnTrue ); + AddIsInjective( category, { cat, obj } -> true ); ## AddBasisOfExternalHom( category, diff --git a/LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi b/LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi index 879799638e..e48b7b0890 100644 --- a/LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi +++ b/LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi @@ -20,39 +20,1075 @@ end; ## AddAdditionForMorphisms( cat, +######## +function ( cat, morphism_1, morphism_2 ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( morphism_1 ), Range, Range( morphism_2 ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, UnderlyingMatrix( morphism_1 ) + UnderlyingMatrix( morphism_2 ) ); +end +######## + + ); + + ## + AddAdditiveInverseForMorphisms( cat, + +######## +function ( cat, morphism ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( morphism ), Range, Range( morphism ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, -1 * UnderlyingMatrix( morphism ) ); +end +######## + + ); + + ## + AddBasisOfExternalHom( cat, + +######## +function ( cat, S, T ) + return List( [ 1 .. Dimension( S ) * Dimension( T ) ], function ( logic_new_func_991_x ) + return VectorSpaceMorphism( S, ConvertRowToMatrix( CertainRows( HomalgIdentityMatrix( Dimension( S ) * Dimension( T ), UnderlyingFieldForHomalg( S ) ), [ logic_new_func_991_x ] ), Dimension( S ), Dimension( T ) ), T ); + end ); +end +######## + + ); + + ## + AddCokernelColift( cat, + +######## +function ( cat, mor, test_object, test_morphism ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := LeftDivide( SyzygiesOfColumns( UnderlyingMatrix( mor ) ), UnderlyingMatrix( test_morphism ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrRows( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), Range, Range( test_morphism ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddCokernelColiftWithGivenCokernelObject( cat, + +######## +function ( cat, mor, test_object, test_morphism, cokernel ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := LeftDivide( SyzygiesOfColumns( UnderlyingMatrix( mor ) ), UnderlyingMatrix( test_morphism ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrRows( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), Range, Range( test_morphism ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddCokernelObject( cat, + +######## +function ( cat, morphism ) + return ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NumberColumns( UnderlyingMatrix( morphism ) ) - RowRankOfMatrix( UnderlyingMatrix( morphism ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ); +end +######## + + ); + + ## + AddCokernelProjection( cat, + +######## +function ( cat, morphism ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := SyzygiesOfColumns( UnderlyingMatrix( morphism ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Range( morphism ), Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrColumns( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddCokernelProjectionWithGivenCokernelObject( cat, + +######## +function ( cat, alpha, with_given_object ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := SyzygiesOfColumns( UnderlyingMatrix( alpha ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Range( alpha ), Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrColumns( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddColift( cat, + +######## +function ( cat, alpha, beta ) + if LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) = fail then + return fail; + else + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Range( alpha ), Range, Range( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ); + fi; + return; +end +######## + + ); + + ## + AddColiftAlongEpimorphism( cat, + +######## +function ( cat, alpha, beta ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Range( alpha ), Range, Range( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ); +end +######## + + ); + + ## + AddDirectSum( cat, + +######## +function ( cat, object_list ) + return ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, Sum( List( object_list, function ( object ) + return Dimension( object ); + end ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ); +end +######## + + ); + + ## + AddDistinguishedObjectOfHomomorphismStructure( cat, + +######## +function ( cat ) + return ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, 1, UnderlyingFieldForHomalg, UnderlyingRing( cat ) ); +end +######## + + ); + + ## + AddEpimorphismFromSomeProjectiveObject( cat, + +######## +function ( cat, obj ) + return IdentityMorphism( obj ); +end +######## + + ); + + ## + AddEpimorphismFromSomeProjectiveObjectWithGivenSomeProjectiveObject( cat, + +######## +function ( arg... ) + return CallFuncList( EpimorphismFromSomeProjectiveObject, arg{[ 1 .. Length( arg ) - 1 ]} ); +end +######## + + ); + + ## + AddHomomorphismStructureOnObjects( cat, + +######## +function ( cat, object_1, object_2 ) + return ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, Dimension( object_1 ) * Dimension( object_2 ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ); +end +######## + + ); + + ## + AddIdentityMorphism( cat, + +######## +function ( cat, object ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, object, Range, object, UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, HomalgIdentityMatrix( Dimension( object ), UnderlyingRing( cat ) ) ); +end +######## + + ); + + ## + AddInjectionOfCofactorOfDirectSum( cat, + +######## +function ( cat, objects, k ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := UnionOfColumns( HomalgZeroMatrix( Dimension( objects[k] ), Sum( objects{[ 1 .. k - 1 ]}, function ( c ) + return Dimension( c ); + end ), UnderlyingRing( cat ) ), HomalgIdentityMatrix( Dimension( objects[k] ), UnderlyingRing( cat ) ), HomalgZeroMatrix( Dimension( objects[k] ), Sum( objects{[ k + 1 .. Length( objects ) ]}, function ( c ) + return Dimension( c ); + end ), UnderlyingRing( cat ) ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, objects[k], Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrColumns( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddInjectionOfCofactorOfDirectSumWithGivenDirectSum( cat, + +######## +function ( cat, object_list, injection_number, coproduct ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, object_list[injection_number], Range, coproduct, UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, UnionOfColumns( HomalgZeroMatrix( Dimension( object_list[injection_number] ), Sum( object_list{[ 1 .. injection_number - 1 ]}, function ( c ) + return Dimension( c ); + end ), UnderlyingRing( cat ) ), HomalgIdentityMatrix( Dimension( object_list[injection_number] ), UnderlyingRing( cat ) ), HomalgZeroMatrix( Dimension( object_list[injection_number] ), Sum( object_list{[ injection_number + 1 .. Length( object_list ) ]}, function ( c ) + return Dimension( c ); + end ), UnderlyingRing( cat ) ) ) ); +end +######## + + ); + + ## + AddInjectiveColift( cat, + +######## +function ( cat, alpha, beta ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Range( alpha ), Range, Range( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ); +end +######## + + ); + + ## + AddInterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure( cat, + +######## +function ( cat, alpha ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := ConvertMatrixToRow( UnderlyingMatrix( alpha ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, 1, UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrColumns( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddInverseForMorphisms( cat, + +######## +function ( cat, mor ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Range( mor ), Range, Source( mor ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, RightDivide( HomalgIdentityMatrix( Dimension( Range( mor ) ), UnderlyingRing( cat ) ), UnderlyingMatrix( mor ) ) ); +end +######## + + ); + + ## + AddIsAutomorphism( cat, + +######## +function ( cat, morphism ) + return Dimension( Source( morphism ) ) = Dimension( Range( morphism ) ) and (Dimension( Range( morphism ) ) = Dimension( Source( morphism ) ) and ColumnRankOfMatrix( UnderlyingMatrix( morphism ) ) = Dimension( Range( morphism ) )); +end +######## + + ); + + ## + AddIsColiftable( cat, + +######## +function ( cat, alpha, beta ) + if LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) = fail then + return IsCapCategoryMorphism( fail ); + else + return IsCapCategoryMorphism( ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Range( alpha ), Range, Range( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, LeftDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ) ); + fi; + return; +end +######## + + ); + + ## + AddIsColiftableAlongEpimorphism( cat, + +######## +function ( cat, epsilon, tau ) + if LeftDivide( UnderlyingMatrix( epsilon ), UnderlyingMatrix( tau ) ) = fail then + return IsCapCategoryMorphism( fail ); + else + return IsCapCategoryMorphism( ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Range( epsilon ), Range, Range( tau ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, LeftDivide( UnderlyingMatrix( epsilon ), UnderlyingMatrix( tau ) ) ) ); + fi; + return; +end +######## + + ); + + ## + AddIsCongruentForMorphisms( cat, + +######## +function ( cat, morphism_1, morphism_2 ) + return UnderlyingMatrix( morphism_1 ) = UnderlyingMatrix( morphism_2 ); +end +######## + + ); + + ## + AddIsEndomorphism( cat, + +######## +function ( cat, morphism ) + return Dimension( Source( morphism ) ) = Dimension( Range( morphism ) ); +end +######## + + ); + + ## + AddIsEpimorphism( cat, + +######## +function ( cat, morphism ) + return ColumnRankOfMatrix( UnderlyingMatrix( morphism ) ) = Dimension( Range( morphism ) ); +end +######## + + ); + + ## + AddIsEqualForCacheForMorphisms( cat, + +######## +function ( cat, mor1, mor2 ) + return IS_IDENTICAL_OBJ( mor1, mor2 ); +end +######## + + ); + + ## + AddIsEqualForCacheForObjects( cat, + +######## +function ( cat, obj1, obj2 ) + return IS_IDENTICAL_OBJ( obj1, obj2 ); +end +######## + + ); + + ## + AddIsEqualForMorphisms( cat, + +######## +function ( cat, mor1, mor2 ) + return UnderlyingMatrix( mor1 ) = UnderlyingMatrix( mor2 ); +end +######## + + ); + + ## + AddIsEqualForObjects( cat, + +######## +function ( cat, object_1, object_2 ) + return Dimension( object_1 ) = Dimension( object_2 ); +end +######## + + ); + + ## + AddIsIdempotent( cat, + +######## +function ( cat, morphism ) + return UnderlyingMatrix( morphism ) * UnderlyingMatrix( morphism ) = UnderlyingMatrix( morphism ); +end +######## + + ); + + ## + AddIsInitial( cat, + +######## +function ( cat, object ) + return Dimension( object ) = 0; +end +######## + + ); + + ## + AddIsInjective( cat, + +######## +function ( cat, obj ) + return true; +end +######## + + ); + + ## + AddIsIsomorphism( cat, + +######## +function ( cat, morphism ) + return Dimension( Range( morphism ) ) = Dimension( Source( morphism ) ) and ColumnRankOfMatrix( UnderlyingMatrix( morphism ) ) = Dimension( Range( morphism ) ); +end +######## + + ); + + ## + AddIsLiftable( cat, + +######## +function ( cat, alpha, beta ) + if RightDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) = fail then + return IsCapCategoryMorphism( fail ); + else + return IsCapCategoryMorphism( ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( alpha ), Range, Source( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, RightDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ) ); + fi; + return; +end +######## + + ); + + ## + AddIsLiftableAlongMonomorphism( cat, + +######## +function ( cat, iota, tau ) + if RightDivide( UnderlyingMatrix( tau ), UnderlyingMatrix( iota ) ) = fail then + return IsCapCategoryMorphism( fail ); + else + return IsCapCategoryMorphism( ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( tau ), Range, Source( iota ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, RightDivide( UnderlyingMatrix( tau ), UnderlyingMatrix( iota ) ) ) ); + fi; + return; +end +######## + + ); + + ## + AddIsMonomorphism( cat, + +######## +function ( cat, morphism ) + return RowRankOfMatrix( UnderlyingMatrix( morphism ) ) = Dimension( Source( morphism ) ); +end +######## + + ); + + ## + AddIsOne( cat, + +######## +function ( cat, morphism ) + return HomalgIdentityMatrix( Dimension( Source( morphism ) ), UnderlyingRing( cat ) ) = UnderlyingMatrix( morphism ); +end +######## + + ); + + ## + AddIsProjective( cat, + +######## +function ( cat, obj ) + return true; +end +######## + + ); + + ## + AddIsSplitEpimorphism( cat, + +######## +function ( cat, morphism ) + if RightDivide( HomalgIdentityMatrix( Dimension( Range( morphism ) ), UnderlyingRing( cat ) ), UnderlyingMatrix( morphism ) ) = fail then + return false; + else + return IsCapCategoryMorphism( ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Range( morphism ), Range, Source( morphism ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, RightDivide( HomalgIdentityMatrix( Dimension( Range( morphism ) ), UnderlyingRing( cat ) ), UnderlyingMatrix( morphism ) ) ) ); + fi; + return; +end +######## + + ); + + ## + AddIsSplitMonomorphism( cat, + +######## +function ( cat, morphism ) + if LeftDivide( UnderlyingMatrix( morphism ), HomalgIdentityMatrix( Dimension( Source( morphism ) ), UnderlyingRing( cat ) ) ) = fail then + return false; + else + return IsCapCategoryMorphism( ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Range( morphism ), Range, Source( morphism ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, LeftDivide( UnderlyingMatrix( morphism ), HomalgIdentityMatrix( Dimension( Source( morphism ) ), UnderlyingRing( cat ) ) ) ) ); + fi; + return; +end +######## - function ( cat, morphism_1, morphism_2 ) + ); + + ## + AddIsTerminal( cat, + +######## +function ( cat, object ) + return Dimension( object ) = 0; +end +######## + + ); + + ## + AddIsWellDefinedForMorphisms( cat, + +######## +function ( cat, morphism ) + if not true then + return false; + elif not IS_IDENTICAL_OBJ( UnderlyingFieldForHomalg( Source( morphism ) ), UnderlyingRing( cat ) ) then + return false; + elif not IS_IDENTICAL_OBJ( UnderlyingFieldForHomalg( morphism ), UnderlyingRing( cat ) ) then + return false; + elif not IS_IDENTICAL_OBJ( UnderlyingFieldForHomalg( Range( morphism ) ), UnderlyingRing( cat ) ) then + return false; + elif NumberRows( UnderlyingMatrix( morphism ) ) <> Dimension( Source( morphism ) ) then + return false; + elif NumberColumns( UnderlyingMatrix( morphism ) ) <> Dimension( Range( morphism ) ) then + return false; + else + return true; + fi; + return; +end +######## + + ); + + ## + AddIsWellDefinedForObjects( cat, + +######## +function ( cat, object ) + if not true then + return false; + elif not IS_IDENTICAL_OBJ( UnderlyingFieldForHomalg( object ), UnderlyingRing( cat ) ) then + return false; + elif Dimension( object ) < 0 then + return false; + else + return true; + fi; + return; +end +######## + + ); + + ## + AddIsZeroForMorphisms( cat, + +######## +function ( cat, morphism ) + return IsZero( UnderlyingMatrix( morphism ) ); +end +######## + + ); + + ## + AddIsZeroForObjects( cat, + +######## +function ( cat, object ) + return Dimension( object ) = 0; +end +######## + + ); + + ## + AddKernelEmbedding( cat, + +######## +function ( cat, morphism ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := SyzygiesOfRows( UnderlyingMatrix( morphism ) ); return ObjectifyWithAttributes( rec( - ), MorphismType( cat ), CapCategory, cat, Source, Source( morphism_1 ), Range, Range( morphism_2 ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, UnderlyingMatrix( morphism_1 ) + UnderlyingMatrix( morphism_2 ) ); + ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrRows( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), Range, Source( morphism ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddKernelEmbeddingWithGivenKernelObject( cat, + +######## +function ( cat, alpha, with_given_object ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := SyzygiesOfRows( UnderlyingMatrix( alpha ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrRows( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), Range, Source( alpha ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); end +######## + + ); + + ## + AddKernelLift( cat, +######## +function ( cat, mor, test_object, test_morphism ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := RightDivide( UnderlyingMatrix( test_morphism ), SyzygiesOfRows( UnderlyingMatrix( mor ) ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( test_morphism ), Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrColumns( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## ); ## - AddPreCompose( cat, + AddKernelLiftWithGivenKernelObject( cat, + +######## +function ( cat, mor, test_object, test_morphism, kernel ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := RightDivide( UnderlyingMatrix( test_morphism ), SyzygiesOfRows( UnderlyingMatrix( mor ) ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( test_morphism ), Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrColumns( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddKernelObject( cat, + +######## +function ( cat, morphism ) + return ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NumberRows( UnderlyingMatrix( morphism ) ) - RowRankOfMatrix( UnderlyingMatrix( morphism ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ); +end +######## + + ); + + ## + AddLift( cat, + +######## +function ( cat, alpha, beta ) + if RightDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) = fail then + return fail; + else + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( alpha ), Range, Source( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, RightDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ); + fi; + return; +end +######## + + ); + + ## + AddLiftAlongMonomorphism( cat, + +######## +function ( cat, alpha, beta ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( beta ), Range, Source( alpha ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, RightDivide( UnderlyingMatrix( beta ), UnderlyingMatrix( alpha ) ) ); +end +######## + + ); + + ## + AddMonomorphismIntoSomeInjectiveObject( cat, + +######## +function ( cat, obj ) + return IdentityMorphism( obj ); +end +######## + + ); + + ## + AddMonomorphismIntoSomeInjectiveObjectWithGivenSomeInjectiveObject( cat, + +######## +function ( arg... ) + return CallFuncList( MonomorphismIntoSomeInjectiveObject, arg{[ 1 .. Length( arg ) - 1 ]} ); +end +######## + + ); + + ## + AddMorphismFromKernelObjectToSink( cat, + +######## +function ( cat, alpha ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := HomalgZeroMatrix( NumberRows( UnderlyingMatrix( alpha ) ) - RowRankOfMatrix( UnderlyingMatrix( alpha ) ), Dimension( Range( alpha ) ), UnderlyingRing( cat ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrRows( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), Range, Range( alpha ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddMorphismFromKernelObjectToSinkWithGivenKernelObject( cat, + +######## +function ( cat, alpha, with_given_object ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := HomalgZeroMatrix( NumberRows( UnderlyingMatrix( alpha ) ) - RowRankOfMatrix( UnderlyingMatrix( alpha ) ), Dimension( Range( alpha ) ), UnderlyingRing( cat ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrRows( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), Range, Range( alpha ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddMorphismFromSourceToCokernelObject( cat, + +######## +function ( cat, alpha ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := HomalgZeroMatrix( Dimension( Source( alpha ) ), NumberColumns( UnderlyingMatrix( alpha ) ) - RowRankOfMatrix( UnderlyingMatrix( alpha ) ), UnderlyingRing( cat ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( alpha ), Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrColumns( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddMorphismFromSourceToCokernelObjectWithGivenCokernelObject( cat, + +######## +function ( cat, alpha, with_given_object ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := HomalgZeroMatrix( Dimension( Source( alpha ) ), NumberColumns( UnderlyingMatrix( alpha ) ) - RowRankOfMatrix( UnderlyingMatrix( alpha ) ), UnderlyingRing( cat ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( alpha ), Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrColumns( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddPostCompose( cat, + +######## +function ( cat, right_mor, left_mor ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( left_mor ), Range, Range( right_mor ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, UnderlyingMatrix( left_mor ) * UnderlyingMatrix( right_mor ) ); +end +######## + ); + + ## + AddPreCompose( cat, - function ( cat, morphism_1, morphism_2 ) +######## +function ( cat, morphism_1, morphism_2 ) return ObjectifyWithAttributes( rec( ), MorphismType( cat ), CapCategory, cat, Source, Source( morphism_1 ), Range, Range( morphism_2 ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, UnderlyingMatrix( morphism_1 ) * UnderlyingMatrix( morphism_2 ) ); end +######## + + ); + + ## + AddProjectionInFactorOfDirectSum( cat, + +######## +function ( cat, objects, k ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := UnionOfRows( HomalgZeroMatrix( Sum( objects{[ 1 .. k - 1 ]}, function ( c ) + return Dimension( c ); + end ), Dimension( objects[k] ), UnderlyingRing( cat ) ), HomalgIdentityMatrix( Dimension( objects[k] ), UnderlyingRing( cat ) ), HomalgZeroMatrix( Sum( objects{[ k + 1 .. Length( objects ) ]}, function ( c ) + return Dimension( c ); + end ), Dimension( objects[k] ), UnderlyingRing( cat ) ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrRows( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), Range, objects[k], UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddProjectionInFactorOfDirectSumWithGivenDirectSum( cat, +######## +function ( cat, object_list, projection_number, direct_sum_object ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, direct_sum_object, Range, object_list[projection_number], UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, UnionOfRows( HomalgZeroMatrix( Sum( object_list{[ 1 .. projection_number - 1 ]}, function ( c ) + return Dimension( c ); + end ), Dimension( object_list[projection_number] ), UnderlyingRing( cat ) ), HomalgIdentityMatrix( Dimension( object_list[projection_number] ), UnderlyingRing( cat ) ), HomalgZeroMatrix( Sum( object_list{[ projection_number + 1 .. Length( object_list ) ]}, function ( c ) + return Dimension( c ); + end ), Dimension( object_list[projection_number] ), UnderlyingRing( cat ) ) ) ); +end +######## ); ## - AddKernelEmbedding( cat, + AddProjectiveLift( cat, + +######## +function ( cat, alpha, beta ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( alpha ), Range, Source( beta ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, RightDivide( UnderlyingMatrix( alpha ), UnderlyingMatrix( beta ) ) ); +end +######## + + ); + + ## + AddSomeInjectiveObject( cat, + +######## +function ( cat, obj ) + return obj; +end +######## + + ); + + ## + AddSomeProjectiveObject( cat, + +######## +function ( cat, obj ) + return obj; +end +######## + + ); + + ## + AddSubtractionForMorphisms( cat, + +######## +function ( cat, mor1, mor2 ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, Source( mor1 ), Range, Range( mor2 ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, UnderlyingMatrix( mor1 ) + -1 * UnderlyingMatrix( mor2 ) ); +end +######## + ); + + ## + AddUniversalMorphismFromDirectSum( cat, - function ( cat, morphism ) +######## +function ( cat, objects, T, tau ) local cap_jit_morphism_attribute; - cap_jit_morphism_attribute := SyzygiesOfRows( UnderlyingMatrix( morphism ) ); + cap_jit_morphism_attribute := UnionOfRows( UnderlyingRing( cat ), Dimension( T ), List( tau, function ( s ) + return UnderlyingMatrix( s ); + end ) ); return ObjectifyWithAttributes( rec( ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( - ), ObjectType( cat ), CapCategory, cat, Dimension, NrRows( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), Range, Source( morphism ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); + ), ObjectType( cat ), CapCategory, cat, Dimension, NrRows( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), Range, T, UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddUniversalMorphismFromDirectSumWithGivenDirectSum( cat, + +######## +function ( cat, diagram, test_object, sink, coproduct ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, coproduct, Range, test_object, UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, UnionOfRows( UnderlyingRing( cat ), Dimension( test_object ), List( sink, function ( s ) + return UnderlyingMatrix( s ); + end ) ) ); +end +######## + + ); + + ## + AddUniversalMorphismFromZeroObject( cat, + +######## +function ( cat, test_sink ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := HomalgZeroMatrix( 0, Dimension( test_sink ), UnderlyingRing( cat ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, 0, UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), Range, test_sink, UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddUniversalMorphismFromZeroObjectWithGivenZeroObject( cat, + +######## +function ( cat, source, zero_object ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, zero_object, Range, source, UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, HomalgZeroMatrix( 0, Dimension( source ), UnderlyingRing( cat ) ) ); +end +######## + + ); + + ## + AddUniversalMorphismIntoDirectSum( cat, + +######## +function ( cat, objects, T, tau ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := UnionOfColumns( UnderlyingRing( cat ), Dimension( T ), List( tau, function ( s ) + return UnderlyingMatrix( s ); + end ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, T, Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, NrColumns( cap_jit_morphism_attribute ), UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddUniversalMorphismIntoDirectSumWithGivenDirectSum( cat, + +######## +function ( cat, diagram, test_object, sink, direct_sum ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, test_object, Range, direct_sum, UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, UnionOfColumns( UnderlyingRing( cat ), Dimension( test_object ), List( sink, function ( s ) + return UnderlyingMatrix( s ); + end ) ) ); +end +######## + + ); + + ## + AddUniversalMorphismIntoZeroObject( cat, + +######## +function ( cat, test_source ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := HomalgZeroMatrix( Dimension( test_source ), 0, UnderlyingRing( cat ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, test_source, Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, 0, UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## + + ); + + ## + AddUniversalMorphismIntoZeroObjectWithGivenZeroObject( cat, + +######## +function ( cat, sink, zero_object ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, sink, Range, zero_object, UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, HomalgZeroMatrix( Dimension( sink ), 0, UnderlyingRing( cat ) ) ); +end +######## + + ); + + ## + AddZeroMorphism( cat, + +######## +function ( cat, source, range ) + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, source, Range, range, UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, HomalgZeroMatrix( Dimension( source ), Dimension( range ), UnderlyingRing( cat ) ) ); +end +######## + + ); + + ## + AddZeroObject( cat, + +######## +function ( cat ) + return ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, 0, UnderlyingFieldForHomalg, UnderlyingRing( cat ) ); end +######## + ); + + ## + AddZeroObjectFunctorial( cat, + +######## +function ( cat ) + local cap_jit_morphism_attribute; + cap_jit_morphism_attribute := HomalgIdentityMatrix( 0, UnderlyingRing( cat ) ); + return ObjectifyWithAttributes( rec( + ), MorphismType( cat ), CapCategory, cat, Source, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, 0, UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), Range, ObjectifyWithAttributes( rec( + ), ObjectType( cat ), CapCategory, cat, Dimension, 0, UnderlyingFieldForHomalg, UnderlyingRing( cat ) ), UnderlyingFieldForHomalg, UnderlyingRing( cat ), UnderlyingMatrix, cap_jit_morphism_attribute ); +end +######## ); From 1fa31d6fe708b2fcaf169e262d980c2ddf96873a Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Mon, 17 May 2021 15:09:38 +0200 Subject: [PATCH 5/6] Make the "/" operation work with the precompiled matrix category --- LinearAlgebraForCAP/gap/MatrixCategoryMorphism.gi | 9 ++++++++- LinearAlgebraForCAP/gap/MatrixCategoryObject.gi | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/LinearAlgebraForCAP/gap/MatrixCategoryMorphism.gi b/LinearAlgebraForCAP/gap/MatrixCategoryMorphism.gi index 4ab495ef7d..e27af46942 100644 --- a/LinearAlgebraForCAP/gap/MatrixCategoryMorphism.gi +++ b/LinearAlgebraForCAP/gap/MatrixCategoryMorphism.gi @@ -125,7 +125,14 @@ end ); InstallMethod( \/, [ IsHomalgMatrix, IsMatrixCategory ], function( homalg_matrix, category ) + local field; + + field := HomalgRing( homalg_matrix ); - return AsVectorSpaceMorphism( homalg_matrix ); + return VectorSpaceMorphism( + MatrixCategoryObject( category, NrRows( homalg_matrix ) ), + homalg_matrix, + MatrixCategoryObject( category, NrColumns( homalg_matrix ) ) + ); end ); diff --git a/LinearAlgebraForCAP/gap/MatrixCategoryObject.gi b/LinearAlgebraForCAP/gap/MatrixCategoryObject.gi index 251b318ba8..e54b6ebd49 100644 --- a/LinearAlgebraForCAP/gap/MatrixCategoryObject.gi +++ b/LinearAlgebraForCAP/gap/MatrixCategoryObject.gi @@ -102,6 +102,6 @@ InstallMethod( \/, [ IsInt, IsMatrixCategory ], function( dim, category ) - return VectorSpaceObject( dim, UnderlyingRing( category ) ); + return MatrixCategoryObject( category, dim ); end ); From b02b07f526ce1b4013e93da2ccbb8e67a5727928 Mon Sep 17 00:00:00 2001 From: Fabian Zickgraf Date: Mon, 17 May 2021 15:10:21 +0200 Subject: [PATCH 6/6] Add example using the precompiled matrix category --- .../examples/ExamplePrecompiled.gi | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 LinearAlgebraForCAP/examples/ExamplePrecompiled.gi diff --git a/LinearAlgebraForCAP/examples/ExamplePrecompiled.gi b/LinearAlgebraForCAP/examples/ExamplePrecompiled.gi new file mode 100644 index 0000000000..9d64bbdbf0 --- /dev/null +++ b/LinearAlgebraForCAP/examples/ExamplePrecompiled.gi @@ -0,0 +1,137 @@ +#! @Chapter Examples and Tests + +#! @Section Basic Commands + +LoadPackage( "LinearAlgebraForCAP" );; + +#! @Example +Q := HomalgFieldOfRationals();; +vec := MatrixCategoryPrecompiled( Q );; +a := MatrixCategoryObject( vec, 3 ); +#! +HasIsProjective( a ) and IsProjective( a ); +#! true +ap := 3/vec;; +IsEqualForObjects( a, ap ); +#! true +b := MatrixCategoryObject( vec, 4 ); +#! +homalg_matrix := HomalgMatrix( [ [ 1, 0, 0, 0 ], + [ 0, 1, 0, -1 ], + [ -1, 0, 2, 1 ] ], 3, 4, Q ); +#! +alpha := VectorSpaceMorphism( a, homalg_matrix, b ); +#! +Display( alpha ); +#! [ [ 1, 0, 0, 0 ], +#! [ 0, 1, 0, -1 ], +#! [ -1, 0, 2, 1 ] ] +#! +#! A morphism in Category of matrices over Q +alphap := homalg_matrix/vec;; +IsCongruentForMorphisms( alpha, alphap ); +#! true +homalg_matrix := HomalgMatrix( [ [ 1, 1, 0, 0 ], + [ 0, 1, 0, -1 ], + [ -1, 0, 2, 1 ] ], 3, 4, Q ); +#! +beta := VectorSpaceMorphism( a, homalg_matrix, b ); +#! +CokernelObject( alpha ); +#! +c := CokernelProjection( alpha );; +Display( c ); +#! [ [ 0 ], +#! [ 1 ], +#! [ -1/2 ], +#! [ 1 ] ] +#! +#! A split epimorphism in Category of matrices over Q +gamma := UniversalMorphismIntoDirectSum( [ c, c ] );; +Display( gamma ); +#! [ [ 0, 0 ], +#! [ 1, 1 ], +#! [ -1/2, -1/2 ], +#! [ 1, 1 ] ] +#! +#! A morphism in Category of matrices over Q +colift := CokernelColift( alpha, gamma );; +IsEqualForMorphisms( PreCompose( c, colift ), gamma ); +#! true +FiberProduct( alpha, beta ); +#! +F := FiberProduct( alpha, beta ); +#! +p1 := ProjectionInFactorOfFiberProduct( [ alpha, beta ], 1 ); +#! +Display( PreCompose( p1, alpha ) ); +#! [ [ 0, 1, 0, -1 ], +#! [ -1, 0, 2, 1 ] ] +#! +#! A morphism in Category of matrices over Q +Pushout( alpha, beta ); +#! +i1 := InjectionOfCofactorOfPushout( [ alpha, beta ], 1 ); +#! +i2 := InjectionOfCofactorOfPushout( [ alpha, beta ], 2 ); +#! +u := UniversalMorphismFromDirectSum( [ b, b ], [ i1, i2 ] ); +#! +Display( u ); +#! [ [ 0, 1, 1, 0, 0 ], +#! [ 1, 0, 1, 0, -1 ], +#! [ -1/2, 0, 1/2, 1, 1/2 ], +#! [ 1, 0, 0, 0, 0 ], +#! [ 0, 1, 0, 0, 0 ], +#! [ 0, 0, 1, 0, 0 ], +#! [ 0, 0, 0, 1, 0 ], +#! [ 0, 0, 0, 0, 1 ] ] +#! +#! A morphism in Category of matrices over Q +KernelObjectFunctorial( u, IdentityMorphism( Source( u ) ), u ) = IdentityMorphism( MatrixCategoryObject( vec, 3 ) ); +#! true +IsZero( CokernelObjectFunctorial( u, IdentityMorphism( Range( u ) ), u ) ); +#! true +DirectProductFunctorial( [ u, u ] ) = DirectSumFunctorial( [ u, u ] ); +#! true +CoproductFunctorial( [ u, u ] ) = DirectSumFunctorial( [ u, u ] ); +#! true +IsOne( FiberProductFunctorial( [ u, u ], [ IdentityMorphism( Source( u ) ), IdentityMorphism( Source( u ) ) ], [ u, u ] ) ); +#! true +IsOne( PushoutFunctorial( [ u, u ], [ IdentityMorphism( Range( u ) ), IdentityMorphism( Range( u ) ) ], [ u, u ] ) ); +#! true +IsCongruentForMorphisms( (1/2) * alpha, alpha * (1/2) ); +#! true +Dimension( HomomorphismStructureOnObjects( a, b ) ) = Dimension( a ) * Dimension( b ); +#! true +IsCongruentForMorphisms( + PreCompose( [ u, DualOnMorphisms( i1 ), DualOnMorphisms( alpha ) ] ), + InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism( Source( u ), Source( alpha ), + PreCompose( + InterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure( DualOnMorphisms( i1 ) ), + HomomorphismStructureOnMorphisms( u, DualOnMorphisms( alpha ) ) + ) + ) +); +#! true +vec := CapCategory( alpha );; +t := TensorUnit( vec );; +z := ZeroObject( vec );; +IsCongruentForMorphisms( + ZeroObjectFunctorial( vec ), + InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism( z, z, ZeroMorphism( t, z ) ) +); +#! true +IsCongruentForMorphisms( + ZeroObjectFunctorial( vec ), + InterpretMorphismFromDistinguishedObjectToHomomorphismStructureAsMorphism( + z, z, + InterpretMorphismAsMorphismFromDistinguishedObjectToHomomorphismStructure( ZeroObjectFunctorial( vec ) ) + ) +); +#! true +right_side := PreCompose( [ i1, DualOnMorphisms( u ), u ] );; +x := SolveLinearSystemInAbCategory( [ [ i1 ] ], [ [ u ] ], [ right_side ] )[1];; +IsCongruentForMorphisms( PreCompose( [ i1, x, u ] ), right_side ); +#! true +#! @EndExample