From 0a20c1b21040a2e3058f1ff7875f43d6629452d8 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 15 Sep 2022 23:40:39 +0200 Subject: [PATCH] Fix `Orbits` with a range as seeds --- lib/oprt.gi | 7 +++++-- tst/testbugfix/2022-09-15-Orbits.tst | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 tst/testbugfix/2022-09-15-Orbits.tst diff --git a/lib/oprt.gi b/lib/oprt.gi index 62b3d0c705..4461258fa5 100644 --- a/lib/oprt.gi +++ b/lib/oprt.gi @@ -1664,7 +1664,7 @@ end ); InstallMethod( Orbits, "for arbitrary domains", true, OrbitsishReq, 0, function( G, D, gens, acts, act ) -local orbs, orb,sort,plist,pos,use,o,nc,ld,ld1; +local orbs, orb,sort,plist,pos,use,o,nc,ld,ld1,pc; sort:=Length(D)>0 and CanEasilySortElements(D[1]); plist:=IsPlistRep(D); @@ -1691,7 +1691,10 @@ local orbs, orb,sort,plist,pos,use,o,nc,ld,ld1; fi; else for o in orb do - use[PositionCanonical(D,o)]:=true; + pc:=PositionCanonical(D,o); + if pc <> fail then + use[pc]:=true; + fi; od; # not plist -- do not take difference as there may be special # `PositionCanonical' method. diff --git a/tst/testbugfix/2022-09-15-Orbits.tst b/tst/testbugfix/2022-09-15-Orbits.tst new file mode 100644 index 0000000000..70c2efc10e --- /dev/null +++ b/tst/testbugfix/2022-09-15-Orbits.tst @@ -0,0 +1,7 @@ +# Verify that Orbits works when the given seeds are a range +# See https://github.com/gap-system/gap/issues/5056 +gap> act := function(omega,g) return PowerModInt(omega,Int(g),15); end;; +gap> ugrp := Units(ZmodnZ(Phi(15))); + +gap> orbs := Orbits(ugrp,[1..5],act); +[ [ 1 ], [ 2, 8 ], [ 3, 12 ], [ 4 ], [ 5 ] ]