diff --git a/gap/quasigroups.gd b/gap/quasigroups.gd index 27ee79a..e874d7b 100644 --- a/gap/quasigroups.gd +++ b/gap/quasigroups.gd @@ -117,7 +117,7 @@ DeclareOperation( "LoopFromFile", [ IsString, IsString ] ); ## CREATING QUASIGROUPS AND LOOPS BY SECTIONS ## ------------------------------------------------------------------------- -DeclareOperation( "CayleyTableByPerms", [ IsPermCollection ] ); +DeclareGlobalFunction("CayleyTableByPerms"); DeclareOperation( "QuasigroupByLeftSection", [ IsPermCollection ] ); DeclareOperation( "LoopByLeftSection", [ IsPermCollection ] ); DeclareOperation( "QuasigroupByRightSection", [ IsPermCollection ] ); diff --git a/gap/quasigroups.gi b/gap/quasigroups.gi index f691a0a..3fa9c69 100644 --- a/gap/quasigroups.gi +++ b/gap/quasigroups.gi @@ -438,30 +438,44 @@ end ); ############################################################################# ## -#O CayleyTableByPerms( perms ) +#O CayleyTableByPerms( perms, [X] ) ## -## Given a set of n permutations of an n-element set X, returns -## n by n Cayley table ct such that ct[i][j] = X[j]^perms[i]. -## The operation is safe only if at most one permutation of is -## the identity permutation, and all other permutations of -## move all points of X. +## Given a set of n permutations of an n-element set of natural +## numbers, returns an n by n Cayley table ct such that +## ct[i][j] = X[j]^perms[i]. +## +## Note that the argument is optional, and if omitted, the function will +## assume that at most one permutation of is the identity +## permutation, and that all other permutations of +## move all points of . -InstallMethod( CayleyTableByPerms, - "for a list of permutations", - [ IsPermCollection ], -function( perms ) +InstallGlobalFunction( CayleyTableByPerms, +function( perms, rest... ) local n, pts, max; n := Length( perms ); if n=1 then return [ [ 1 ] ]; fi; + # one of perms[ 1 ], perms[ 2 ] must move all points - pts := MovedPoints( perms[ 2 ] ); - if pts = [] then + if Length(rest) > 0 then + pts := rest[0]; + else + pts := MovedPoints( perms[ 2 ] ); + if pts = [] then pts := MovedPoints( perms[ 1 ] ); + fi; + fi; + if Length(pts) <> n then + Error("perms for cayley table of size ", n, " cannot act on ", + Length(pts), " points."); fi; max := Maximum( pts ); - # we permute the whole interval [1..max] and then keep only those coordinates corresponding to pts + if max = n then + # Common case, we are permuting [1..n] + return List( perms, x -> ListPerm(x, n)); + fi; + # Otherwise we permute the whole interval [1..max] and then keep only those coordinates corresponding to pts return List( perms, p -> Permuted( [1..max], p^(-1) ){ pts } ); end);