From 4ea073847359653b0c7395b320084015651866af Mon Sep 17 00:00:00 2001 From: Sergio Siccha Date: Wed, 15 May 2019 12:30:42 +0200 Subject: [PATCH] lib: add operation DirectProductFamily This declares the new operation DirectProductFamily and installs a method for it. The new method is also added to `hpcgap/lib/tuples.gi`. Also adds documentation and tests. In the reference manual, the section "IsDirectProductElement (Filter)" is renamed into "Direct Products and their Elements" to also accomodate the documentation of DirectProductFamily and future categories and operations. UnderlyingRelation is adapted to use the new method, which makes it easier to read. The same change is replicated to `hpcgap/lib/mapping.gi`. --- doc/ref/mapping.xml | 5 ++-- hpcgap/lib/mapping.gi | 11 ++++----- hpcgap/lib/tuples.gi | 14 +++++++++++ lib/mapping.gi | 11 ++++----- lib/tuples.gd | 49 ++++++++++++++++++++++++++++++++++++++ lib/tuples.gi | 14 +++++++++++ tst/testinstall/tuples.tst | 13 ++++++++++ 7 files changed, 103 insertions(+), 14 deletions(-) create mode 100644 tst/testinstall/tuples.tst diff --git a/doc/ref/mapping.xml b/doc/ref/mapping.xml index bede5f6d51..148e0d938e 100644 --- a/doc/ref/mapping.xml +++ b/doc/ref/mapping.xml @@ -37,10 +37,11 @@ section . -
-IsDirectProductElement (Filter) +
+Direct Products and their Elements <#Include Label="IsDirectProductElement"> +<#Include Label="DirectProductFamily">
diff --git a/hpcgap/lib/mapping.gi b/hpcgap/lib/mapping.gi index 025375e617..586928eabc 100644 --- a/hpcgap/lib/mapping.gi +++ b/hpcgap/lib/mapping.gi @@ -1262,12 +1262,11 @@ InstallMethod( UnderlyingRelation, true, [ IsGeneralMapping ], 0, function( map ) - local rel; - rel:= Objectify( NewType( CollectionsFamily( - DirectProductElementsFamily( [ ElementsFamily( FamilyObj( Source( map ) ) ), - ElementsFamily( FamilyObj( Range( map ) ) ) ] ) ), - IsDomain and IsAttributeStoringRep ), - rec() ); + local type, rel; + type:= NewType( DirectProductFamily( [ FamilyObj( Source( map ) ), + FamilyObj( Range( map ) ) ] ), + IsDomain and IsAttributeStoringRep ); + rel:= Objectify( type, rec() ); SetUnderlyingGeneralMapping( rel, map ); return rel; end ); diff --git a/hpcgap/lib/tuples.gi b/hpcgap/lib/tuples.gi index 628db60a34..edaa1476ea 100644 --- a/hpcgap/lib/tuples.gi +++ b/hpcgap/lib/tuples.gi @@ -512,3 +512,17 @@ InstallOtherMethod( \*, fi; return DirectProductElement( List( dpelm, entry -> nonlist * entry ) ); end ); + + +############################################################################# +## +## +InstallGlobalFunction( DirectProductFamily, + function( args ) + if not IsDenseList(args) or not ForAll(args, IsCollectionFamily) then + ErrorNoReturn(" must be a dense list of collection families"); + fi; + return CollectionsFamily( + DirectProductElementsFamily( List( args, ElementsFamily ) ) + ); + end ); diff --git a/lib/mapping.gi b/lib/mapping.gi index df6b8fbda8..fb1ff71e9a 100644 --- a/lib/mapping.gi +++ b/lib/mapping.gi @@ -1259,12 +1259,11 @@ InstallMethod( UnderlyingRelation, true, [ IsGeneralMapping ], 0, function( map ) - local rel; - rel:= Objectify( NewType( CollectionsFamily( - DirectProductElementsFamily( [ ElementsFamily( FamilyObj( Source( map ) ) ), - ElementsFamily( FamilyObj( Range( map ) ) ) ] ) ), - IsDomain and IsAttributeStoringRep ), - rec() ); + local type, rel; + type:= NewType( DirectProductFamily( [ FamilyObj( Source( map ) ), + FamilyObj( Range( map ) ) ] ), + IsDomain and IsAttributeStoringRep ); + rel:= Objectify( type, rec() ); SetUnderlyingGeneralMapping( rel, map ); return rel; end ); diff --git a/lib/tuples.gd b/lib/tuples.gd index 0982901bf5..8d3f9b7648 100644 --- a/lib/tuples.gd +++ b/lib/tuples.gd @@ -178,3 +178,52 @@ direct product elements families" ); DeclareOperation( "DirectProductElement", [ IsList ]); DeclareOperation( "DirectProductElementNC", [ IsDirectProductElementFamily, IsList ]); + + +############################################################################# +## +## +## <#GAPDoc Label="DirectProductFamily"> +## +## +## +## +## args must be a dense list of +## families, otherwise the function raises an error. +##

+## returns fam, a collections +## family of objects. +##

+## fam is the of +## objects +## whose i-th component is in ElementsFamily(args[i]). +##

+## Note that a collection in fam may not itself be a +## direct product; it just is a subcollection of a direct product. +##

+## D8 := DihedralGroup(IsPermGroup, 8);; +## gap> FamilyObj(D8) = CollectionsFamily(PermutationsFamily); +## true +## gap> fam := DirectProductFamily([FamilyObj(D8), FamilyObj(D8)]);; +## gap> ComponentsOfDirectProductElementsFamily(ElementsFamily(fam)); +## [ , ] +## ]]> +## Also note that not all direct products in &GAP; are created via these +## families. For example if the arguments to +## are permutation groups, then it returns a permutation group as well, whose +## elements are not objects. +##

+## fam = FamilyObj(DirectProduct(D8, D8)); +## false +## gap> D4 := DihedralGroup(IsPcGroup, 4);; +## gap> fam2 := DirectProductFamily([FamilyObj(D8), FamilyObj(D4)]);; +## gap> fam2 = FamilyObj(DirectProduct(D8, D4)); +## true +## ]]> +## +## +## <#/GAPDoc> +DeclareGlobalFunction( "DirectProductFamily", + "for a dense list of collection families" ); diff --git a/lib/tuples.gi b/lib/tuples.gi index 15bd75a44a..a4bb72148f 100644 --- a/lib/tuples.gi +++ b/lib/tuples.gi @@ -506,3 +506,17 @@ InstallOtherMethod( \*, fi; return DirectProductElement( List( dpelm, entry -> nonlist * entry ) ); end ); + + +############################################################################# +## +## +InstallGlobalFunction( DirectProductFamily, + function( args ) + if not IsDenseList(args) or not ForAll(args, IsCollectionFamily) then + ErrorNoReturn(" must be a dense list of collection families"); + fi; + return CollectionsFamily( + DirectProductElementsFamily( List( args, ElementsFamily ) ) + ); + end ); diff --git a/tst/testinstall/tuples.tst b/tst/testinstall/tuples.tst new file mode 100644 index 0000000000..a1f0fe18bc --- /dev/null +++ b/tst/testinstall/tuples.tst @@ -0,0 +1,13 @@ +gap> START_TEST("tuples.tst"); +gap> D8 := DihedralGroup(IsPermGroup, 8);; +gap> fam := FamilyObj(D8); + +gap> ElementsFamily(fam); + +gap> dpf := DirectProductFamily([fam, fam]); + +gap> IsDirectProductElementFamily(ElementsFamily(dpf)); +true + +# +gap> STOP_TEST("tuples.tst");