Skip to content

Commit 39e0986

Browse files
authored
Merge pull request #705 from zickgraf/precompiled_tower_constructors
Add experimental code to AdditiveClosure which allows to load precompiled code automatically
2 parents 9e2064d + 1edc647 commit 39e0986

File tree

6 files changed

+48
-7
lines changed

6 files changed

+48
-7
lines changed

CompilerForCAP/gap/PrecompileCategory.gi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ InstallGlobalFunction( "CapJitPrecompileCategory", function ( category_construct
265265
fi;
266266

267267
# check that category_constructor supports `FinalizeCategory` and `enable_compilation`
268-
cat := CallFuncList( category_constructor, given_arguments : FinalizeCategory := false, enable_compilation := true );
268+
cat := CallFuncList( category_constructor, given_arguments : FinalizeCategory := false, enable_compilation := true, no_precompiled_code := true );
269269

270270
if HasIsFinalized( cat ) then
271271

@@ -351,7 +351,7 @@ InstallGlobalFunction( "CapJitPrecompileCategory", function ( category_construct
351351
" \n",
352352
" \n",
353353
" \n",
354-
" cat := category_constructor( ", parameters_string, " : FinalizeCategory := false );\n"
354+
" cat := category_constructor( ", parameters_string, " : FinalizeCategory := false, no_precompiled_code := true );\n"
355355
);
356356
output_string := Concatenation( output_string, current_string );
357357

FreydCategoriesForCAP/gap/AdditiveClosure.gi

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,53 @@ InstallMethod( AdditiveClosure,
1515
[ IsCapCategory ],
1616

1717
function( underlying_category )
18-
local category, matrix_element_as_morphism, list_list_as_matrix, homalg_ring, to_be_finalized;
18+
local precompiled_tower_constructors, constructors_in_tower, precompiled_category_getter, category, matrix_element_as_morphism, list_list_as_matrix, homalg_ring, to_be_finalized, info;
1919

2020
if not ( HasIsAbCategory( underlying_category ) and IsAbCategory( underlying_category ) ) then
2121

2222
Error( "The underlying category has to be an Ab-category" );
2323

2424
fi;
2525

26+
# EXPERIMENTAL
27+
precompiled_tower_constructors := [ ];
28+
29+
if IsBound( underlying_category!.compiler_hints ) and IsBound( underlying_category!.compiler_hints.precompiled_tower_constructors ) then
30+
31+
for info in underlying_category!.compiler_hints.precompiled_tower_constructors do
32+
33+
constructors_in_tower := info.constructors_in_tower;
34+
precompiled_category_getter := info.precompiled_category_getter;
35+
36+
if constructors_in_tower[1] = "AdditiveClosure" then
37+
38+
if Length( constructors_in_tower ) = 1 and ValueOption( "no_precompiled_code" ) <> true then
39+
40+
# try to get precompiled version
41+
category := CallFuncList( precompiled_category_getter, [ underlying_category ] );
42+
43+
if category <> fail then
44+
45+
return category;
46+
47+
fi;
48+
49+
else
50+
51+
# pass information on to the next level
52+
Add( precompiled_tower_constructors, rec(
53+
constructors_in_tower := constructors_in_tower{[ 2 .. Length( constructors_in_tower ) ]},
54+
precompiled_category_getter := precompiled_category_getter,
55+
) );
56+
57+
fi;
58+
59+
fi;
60+
61+
od;
62+
63+
fi;
64+
2665
category := CreateCapCategory( Concatenation( "Additive closure( ", Name( underlying_category )," )" ) );
2766

2867
category!.category_as_first_argument := true;
@@ -31,6 +70,8 @@ InstallMethod( AdditiveClosure,
3170
category_attribute_names := [
3271
"UnderlyingCategory",
3372
],
73+
# EXPERIMENTAL
74+
precompiled_tower_constructors := precompiled_tower_constructors,
3475
);
3576

3677
matrix_element_as_morphism := ValueOption( "matrix_element_as_morphism" );

FreydCategoriesForCAP/gap/precompiled_categories/CategoryOfColumnsOfFieldPrecompiled.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ end;
1515

1616

1717

18-
cat := category_constructor( field : FinalizeCategory := false );
18+
cat := category_constructor( field : FinalizeCategory := false, no_precompiled_code := true );
1919

2020
##
2121
AddAdditionForMorphisms( cat,

FreydCategoriesForCAP/gap/precompiled_categories/OppositeOfCategoryOfRowsOfFieldPrecompiled.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ end;
1515

1616

1717

18-
cat := category_constructor( field : FinalizeCategory := false );
18+
cat := category_constructor( field : FinalizeCategory := false, no_precompiled_code := true );
1919

2020
##
2121
AddAdditionForMorphisms( cat,

LinearAlgebraForCAP/gap/precompiled_categories/MatrixCategoryPrecompiled.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ end;
1515

1616

1717

18-
cat := category_constructor( field : FinalizeCategory := false );
18+
cat := category_constructor( field : FinalizeCategory := false, no_precompiled_code := true );
1919

2020
##
2121
AddAdditionForMorphisms( cat,

LinearAlgebraForCAP/gap/precompiled_categories/OppositeOfMatrixCategoryPrecompiled.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ end;
1616

1717

1818

19-
cat := category_constructor( field : FinalizeCategory := false );
19+
cat := category_constructor( field : FinalizeCategory := false, no_precompiled_code := true );
2020

2121
##
2222
AddAdditionForMorphisms( cat,

0 commit comments

Comments
 (0)