Skip to content

Commit 094948d

Browse files
Merge pull request #244 from mohamed-barakat/precompileProjectionInFactorOfBinaryDirectProduct
precompile ProjectionInFactorOfBinaryDirectProduct for two objects
2 parents f323cca + bae7e69 commit 094948d

File tree

3 files changed

+80
-3
lines changed

3 files changed

+80
-3
lines changed

PackageInfo.g

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SetPackageInfo( rec(
1010

1111
PackageName := "FinSetsForCAP",
1212
Subtitle := "The elementary topos of (skeletal) finite sets",
13-
Version := "2024.02-03",
13+
Version := "2024.02-04",
1414

1515
Date := (function ( ) if IsBound( GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE ) then return GAPInfo.SystemEnvironment.GAP_PKG_RELEASE_DATE; else return Concatenation( ~.Version{[ 1 .. 4 ]}, "-", ~.Version{[ 6, 7 ]}, "-01" ); fi; end)( ),
1616
License := "GPL-2.0-or-later",

examples/PrecompileCategoryOfSkeletalFinSetsWithMorphismsGivenByLists.g

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ LoadPackage( "FinSetsForCAP", false );
1010
#! true
1111
LoadPackage( "CompilerForCAP", ">= 2023.10-03", false );
1212
#! true
13-
14-
ReadPackage( "FinSetsForCAP", "gap/CompilerLogic.gi" );
13+
ReadPackageOnce( "FinSetsForCAP", "gap/CompilerLogic.gi" );
1514
#! true
1615

1716
category_constructor := {} -> SkeletalCategoryOfFiniteSets( );;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#! @Chapter Precompilation
2+
3+
#! @Section Precompiling ProjectionInFactorOfBinaryDirectProduct
4+
5+
#! @Example
6+
7+
#! #@if ValueOption( "no_precompiled_code" ) <> true
8+
9+
LoadPackage( "FinSetsForCAP", false );
10+
#! true
11+
LoadPackage( "CompilerForCAP", ">= 2023.12-09", false );
12+
#! true
13+
ReadPackageOnce( "FinSetsForCAP", "gap/CompilerLogic.gi" );
14+
#! true
15+
16+
sFinSets := CategoryOfSkeletalFinSets( : no_precompiled_code := true );
17+
#! SkeletalFinSets
18+
19+
LeftProjectionInFactorOfBinaryDirectProduct :=
20+
function( cat, a, b, axb )
21+
return ProjectionInFactorOfDirectProductWithGivenDirectProduct( cat,
22+
[ a, b ],
23+
1,
24+
axb ); end;
25+
#! function( cat, a, b, axb ) ... end
26+
27+
RightProjectionInFactorOfBinaryDirectProduct :=
28+
function( cat, a, b, axb )
29+
return ProjectionInFactorOfDirectProductWithGivenDirectProduct( cat,
30+
[ a, b ],
31+
2,
32+
axb ); end;
33+
#! function( cat, a, b, axb ) ... end
34+
35+
StartTimer( "ProjectionInFactorOfBinaryDirectProduct" );
36+
37+
compiled_LeftProjectionInFactorOfBinaryDirectProduct :=
38+
CapJitCompiledFunction( LeftProjectionInFactorOfBinaryDirectProduct,
39+
sFinSets,
40+
[ "category", "object", "object", "object" ],
41+
"morphism" );
42+
#! function( cat_1, a_1, b_1, axb_1 ) ... end
43+
44+
compiled_RightProjectionInFactorOfBinaryDirectProduct :=
45+
CapJitCompiledFunction( RightProjectionInFactorOfBinaryDirectProduct,
46+
sFinSets,
47+
[ "category", "object", "object", "object" ],
48+
"morphism" );
49+
#! function( cat_1, a_1, b_1, axb_1 ) ... end
50+
51+
StopTimer( "ProjectionInFactorOfBinaryDirectProduct" );
52+
#DisplayTimer( "ProjectionInFactorOfBinaryDirectProduct" );
53+
54+
Display( compiled_LeftProjectionInFactorOfBinaryDirectProduct );
55+
#! function ( cat_1, a_1, b_1, axb_1 )
56+
#! local hoisted_1_1, deduped_3_1;
57+
#! deduped_3_1 := Length( axb_1 );
58+
#! hoisted_1_1 := Length( a_1 );
59+
#! return CreateCapCategoryMorphismWithAttributes( cat_1, axb_1, a_1,
60+
#! AsList, List( [ 0 .. deduped_3_1 - 1 ], function ( i_2 )
61+
#! return RemIntWithDomain( i_2, hoisted_1_1, deduped_3_1 );
62+
#! end ) );
63+
#! end
64+
65+
Display( compiled_RightProjectionInFactorOfBinaryDirectProduct );
66+
#! function ( cat_1, a_1, b_1, axb_1 )
67+
#! local hoisted_1_1, deduped_3_1;
68+
#! deduped_3_1 := Length( axb_1 );
69+
#! hoisted_1_1 := Length( a_1 );
70+
#! return CreateCapCategoryMorphismWithAttributes( cat_1, axb_1, b_1,
71+
#! AsList, List( [ 0 .. deduped_3_1 - 1 ], function ( i_2 )
72+
#! return QuoIntWithDomain( i_2, hoisted_1_1, deduped_3_1 );
73+
#! end ) );
74+
#! end
75+
76+
#! #@fi
77+
78+
#! @EndExample

0 commit comments

Comments
 (0)