Thank you Vincent, that's what I am looking for.
I did the test to compare the speed, I did it first for small groups repeat 5000 times, then for large groups.
test on small groups repeat 5000 times.
Runing time for ClosureGroup(H,J) is 0:00:25.837925
Runing time for ClosureGroup(H,w) is 0:00:21.571264
Runing time for PermutationGroup(H.gens()+J.gens()) is 0:00:00.943834
Runing time for PermutationGroup(H.gens()+list(w)) is 0:00:00.810795
test on large groups only 1 time.
Runing time for ClosureGroup(H,J) is 0:01:09.245275
Runing time for ClosureGroup(H,w) is 0:01:10.550019
Runing time for PermutationGroup(H.gens()+J.gens()) is 0:00:00.001400
Runing time for PermutationGroup(H.gens()+list(w)) is 0:00:00.000649
Notes: 25.837925
means 25 seconds, 0:01:09.245275
means 1 minutes and 9 seconds.
H
and J
are groups, w
is a generator of a group, somehow PermutationGroup(H.gens()+J.gens())
is way faster than ClosureGroup
, maybe ClosureGroup
is doing some extra validation or computation?
Here is the python/sage code:
from sage.all import *
from datetime import datetime
case = 'small'
#case = 'large'
if case == 'small':
H = PermutationGroup([(2,3),(4,5)])
J = PermutationGroup([(1,2),(3,4,5)])
W = PermutationGroup([(1,4)])
w = W.gen(0)
iteration = 5000
print 'test on small groups repeat {0} times.'.format(iteration)
elif case == 'large':
H = CyclicPermutationGroup(200)
J = AlternatingGroup(200)
W = AlternatingGroup(200)
#J = DihedralGroup(10000)
#W = DihedralGroup(10000)
w = W.gen(1)
iteration = 1
print 'test on large groups only {0} time.'.format(iteration)
start = datetime.now()
for i in range(iteration):
P1_gap = gap.ClosureGroup(H,J) # close two group
P1 = PermutationGroup(gap_group=P1_gap)
print 'Runing time for ClosureGroup(H,J) is {0}'.format(str(datetime.now() - start))
start = datetime.now()
for i in range(iteration):
P2_gap = gap.ClosureGroup(H,w) # close one group with one generator
P2 = PermutationGroup(gap_group=P2_gap)
print 'Runing time for ClosureGroup(H,w) is {0}'.format(str(datetime.now() - start))
start = datetime.now()
for i in range(iteration):
P3 = PermutationGroup(H.gens()+J.gens())
print 'Runing time for PermutationGroup(H.gens()+J.gens()) is {0}'.format(str(datetime.now() - start))
start = datetime.now()
for i in range(iteration):
P4 = PermutationGroup(H.gens()+list(w))
print 'Runing time for PermutationGroup(H.gens()+list(w)) is {0}'.format(str(datetime.now() - start))