Skip to content

Commit

Permalink
ENHANCE: Hashing for perms on integerlists
Browse files Browse the repository at this point in the history
Gives significant speedup to orbit calculations of permutations on
integer lists.
This has releveance for gap-system#5040
  • Loading branch information
hulpke committed Oct 28, 2022
1 parent 618b058 commit fe4d30a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/dicthf.gi
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ BindGlobal("HashKeyWholeBag", {x,y} -> HASHKEY_BAG(x,y,0,-1));

#############################################################################
##
#M DenseIntKey(<objcol>)
#M SparseIntKey(<objcol>)
##
InstallMethod(SparseIntKey,"for finite Gaussian row spaces",true,
[ IsFFECollColl and IsGaussianRowSpace,IsObject ], 0,
Expand Down Expand Up @@ -130,6 +130,25 @@ local f,n,bytelen,data,qq,i;
fi;
end);

#############################################################################
##
#M SparseIntKey(<objcol>)
##
InstallMethod(SparseIntKey,"for bounded tuples",true,
[ IsList,IsList and IsCyclotomicCollection ], 0,
function(m,v)
local c,t;
if Length(m)<>3 or m[1]<>"BoundedTuples" then
TryNextMethod();
fi;
t:=Maximum(m[2])+1;
c:=[1,Maximum(m[2])+1];
return function(a)
return a*c;
end;

end);

SparseIntKeyVecListAndMatrix:=function(d,m)
local f,n,pow,fct;
if IsList(d) and Length(d)>0 and IsMatrix(d[1]) then
Expand Down
17 changes: 17 additions & 0 deletions lib/oprt.gi
Original file line number Diff line number Diff line change
Expand Up @@ -3559,6 +3559,23 @@ local xset,dom,D,b,t,i,r,binv,pos,kero,dets,roots,dim,f;
return fail; # no extra vector found
end);

#############################################################################
##
#M DomainForAction( <pnt>, <acts>,<act> )
##
InstallMethod(DomainForAction,"permutations on lists of integers",true,
[IsList,IsListOrCollection and IsPermCollection,IsFunction],0,
function(pnt,acts,act)
local m;
if not (Length(pnt)>0 and ForAll(pnt,IsPosInt) and
(act=OnSets or act=OnPoints or act=OnRight or act=\^)) then
TryNextMethod();
fi;
m:=Maximum(Maximum(pnt),LargestMovedPoint(acts));
# workaround to avoid creating formal objects of bounded tuples
return ["BoundedTuples",[1..m],Length(pnt)];
end);

#############################################################################
##
#M DomainForAction( <pnt>, <acts>,<act> )
Expand Down

0 comments on commit fe4d30a

Please sign in to comment.