99# For the actually new points and their ids act on them by all the generators
1010# make a list of triples: pt, parent id, gen used and cut it into blocks of
1111# some suitable size. Run task on each block
12-
12+
1313#
1414
1515#
1616# dict is a thread-safe data structure (blocked hash table perhaps)
17- # it supports AddOrLookup(dict, obj)
17+ # it supports AddOrLookup(dict, obj)
1818# if obj is in dict already, it returns the id assigned when obj was added
1919# if obj is not already in dict, it returns -(a new id)
2020# The IDs are small positive ints, and while they may not be contiguous they shouldn't be too huge.
@@ -27,12 +27,12 @@ NHASHTABLES := 17;
2727
2828newSplitHashTableDict := function (hash1, hash2, npieces, magic )
2929 local r, tables, t, i;
30- r := rec (npieces := npieces, hash1 := hash1, hash2 := hash2, magic := magic,
30+ r := rec (npieces := npieces, hash1 := hash1, hash2 := hash2, magic := magic,
3131 tables := [] );
3232 for i in [ 1 .. npieces] do
33- r.tables[ i] := rec (next := 1 + (i- 1 )* magic, top := i* magic, table :=
33+ r.tables[ i] := rec (next := 1 + (i- 1 )* magic, top := i* magic, table :=
3434 SparseHashTable(hash2));
35-
35+
3636 od ;
3737 for t in r.tables do
3838 ShareObj(t);
@@ -42,7 +42,7 @@ newSplitHashTableDict := function(hash1, hash2, npieces, magic)
4242end ;
4343
4444#
45- # Two approaches to managing the hash tables.
45+ # Two approaches to managing the hash tables.
4646# optimum might well be to switch from 1 to 2
4747# once the rediscovery rate gets high enough.
4848#
@@ -78,7 +78,7 @@ SHTaddOrLookup2 := function(dict, obj)
7878 if ht = fail then
7979 atomic readwrite t do
8080 ht := GetHashEntry(t.table,obj);
81- if ht = fail then
81+ if ht = fail then
8282 ht := t.next;
8383 t.next := t.next+ 1 ;
8484 if t.next > t.top then
@@ -89,7 +89,7 @@ SHTaddOrLookup2 := function(dict, obj)
8989 return - ht;
9090 fi ;
9191 od ;
92-
92+
9393 fi ;
9494 return ht;
9595end ;
@@ -105,7 +105,7 @@ task := function( points, parentids, gennos, gens, action, dict, addOrLookup, re
105105 MakeImmutable(parents);
106106 MakeImmutable(ngennos);
107107 ATOMIC_ADDITION(l,1 ,1 );
108- ATOMIC_ADDITION(l,2 ,1 );
108+ ATOMIC_ADDITION(l,2 ,1 );
109109 RunAsyncTask(task, npts, parents, ngennos, gens, action, dict, addOrLookup, record, l, sem);
110110 end ;
111111 npts := [] ;
@@ -130,8 +130,8 @@ task := function( points, parentids, gennos, gens, action, dict, addOrLookup, re
130130 od ;
131131 if Length(parents) > 0 then
132132 emit();
133- fi ;
134-
133+ fi ;
134+
135135 ATOMIC_ADDITION(l,1 ,- 1 );
136136 if l[ 1 ] = 0 then
137137 SignalSemaphore(sem);
@@ -154,7 +154,7 @@ HTaddOrLookup := function(ht, obj)
154154 return res;
155155end ;
156156
157-
157+
158158
159159seqorb := function ( seeds, gens, action, dict, addOrLookup, record )
160160 local queue, qids, i, ngens, pt, npt, newid,j ;
@@ -177,30 +177,34 @@ seqorb := function( seeds, gens, action, dict, addOrLookup, record)
177177 od ;
178178end ;
179179
180-
181-
182-
180+
181+
182+
183183parorb := function ( seeds, gens, action, dict, addOrLookup, record )
184184 local l, sem, fakes;
185185 l := FixedAtomicList([ 0 ,0 ] );
186186 sem := CreateSemaphore(0 );
187187 seeds := Immutable(seeds);
188188 fakes := `List(seeds, s-> fail );
189189 ATOMIC_ADDITION(l, 1 , 1 );
190- ATOMIC_ADDITION(l,2 ,1 );
190+ ATOMIC_ADDITION(l,2 ,1 );
191191 RunAsyncTask(task, seeds, fakes, fakes, gens, action, dict, addOrLookup, record, l, sem);
192192# while true do Print(l[1]," ",l[2],"\n");
193193 # od;
194194 if l[ 1 ] > 0 then
195195 WaitSemaphore(sem);
196196 fi ;
197-
197+
198198 return l[ 2 ] ;
199199end ;
200200
201- hash := function (s )
201+ hash := function (s )
202202 local sp;
203- sp := AsPlist(s);
203+ if IsPlistRep(x) then
204+ sp := s;
205+ else
206+ sp := PlainListCopy(s);
207+ fi ;
204208 return HashKeyBag(sp, 0 ,0 ,SIZE_OBJ(sp));
205209end ;
206210
@@ -252,44 +256,44 @@ actionViaParOrb := function(seeds, gens, action, hash)
252256 return realacts;
253257end ;
254258
255-
259+
256260
257261m24trial := function ()
258262 local d, gens, orb;
259263 orb := AtomicList([] );
260264 d := newSplitHashTableDict(x-> x, x-> x, NHASHTABLES, 100 );
261265 gens := GeneratorsOfGroup(MathieuGroup(24 ));
262- parorb([ 1 ] , gens, OnPoints, d, SHTaddOrLookup, function (a,b,c )
266+ parorb([ 1 ] , gens, OnPoints, d, SHTaddOrLookup, function (a,b,c )
263267 end );
264268 return keysOfSHT(d);
265-
269+
266270end ;
267271
268272m24trialn := function (n )
269273 local d, gens;
270274 d := newSplitHashTableDict(hash, hash, NHASHTABLES, 100 );
271275 gens := GeneratorsOfGroup(MathieuGroup(24 ));
272- parorb([ `[ 1 .. n]] , gens, OnSets, d, SHTaddOrLookup, function (a,b,c )
276+ parorb([ `[ 1 .. n]] , gens, OnSets, d, SHTaddOrLookup, function (a,b,c )
273277 end );
274278 return keysOfSHT(d);
275-
279+
276280end ;
277281
278282m24seqtrialn := function (n )
279283 local d, gens, orb;
280284 orb := [] ;
281- d := SeqDict(hash);
285+ d := SeqDict(hash);
282286 gens := GeneratorsOfGroup(MathieuGroup(24 ));
283- seqorb([ AsPlist ([ 1 .. n] )] , gens, OnSets, d, HTaddOrLookup, function (a,b,c )
287+ seqorb([ PlainListCopy ([ 1 .. n] )] , gens, OnSets, d, HTaddOrLookup, function (a,b,c )
284288 end );
285289 return Filtered(d.table!. KeyArray, x-> x<> fail );
286290end ;
287291
288292m24act := function (n )
289293 local gens;
290294 gens := GeneratorsOfGroup(MathieuGroup(24 ));
291- return actionViaParOrb([ `AsPlist ([ 1 .. n] )] , gens, OnSets, hash);
295+ return actionViaParOrb([ `PlainListCopy ([ 1 .. n] )] , gens, OnSets, hash);
292296end ;
293297
294-
295-
298+
299+
0 commit comments