Group generation made deterministic.

Former-commit-id: ee2f92e71427c11348e8fad8c8cee2dfa16fd3d8
This commit is contained in:
Marek Nečada 2019-03-07 05:09:44 +00:00
parent 1d77d76b80
commit 0fb36f1e4c
2 changed files with 16 additions and 2 deletions

View File

@ -1185,7 +1185,7 @@ cdef class FinitePointGroup:
'''Constructs a FinitePointGroup from PointGroupInfo''' '''Constructs a FinitePointGroup from PointGroupInfo'''
# TODO maybe I might use a try..finally statement to avoid leaks # TODO maybe I might use a try..finally statement to avoid leaks
# First, generate all basic data from info # First, generate all basic data from info
permlist = list(info.permgroup.elements) permlist = info.deterministic_elemlist()
cdef int order = len(permlist) cdef int order = len(permlist)
permindices = {perm: i for i, perm in enumerate(permlist)} # 'invert' permlist permindices = {perm: i for i, perm in enumerate(permlist)} # 'invert' permlist
identity = info.permgroup.identity identity = info.permgroup.identity

View File

@ -29,6 +29,15 @@ def grouprep_try(tdict, src, im, srcgens, imgens, immultop = None, imcmp = None)
raise ValueError("Homomorphism inconsistency detected") raise ValueError("Homomorphism inconsistency detected")
return return
def group_dps_try(elemlist, elem, gens):
'''Deterministic group depth-first search'''
elemlist.append(elem)
for i in range(len(gens)):
newelem = elem * gens[i]
if newelem not in elemlist:
group_dps_try(elemlist, newelem, gens)
return
class SVWFPointGroupInfo: # only for point groups, coz in svwf_rep() I use I_tyty, not I_ptypty or something alike class SVWFPointGroupInfo: # only for point groups, coz in svwf_rep() I use I_tyty, not I_ptypty or something alike
def __init__(self, def __init__(self,
name, name,
@ -60,6 +69,11 @@ class SVWFPointGroupInfo: # only for point groups, coz in svwf_rep() I use I_tyt
immultop = None, imcmp = (lambda x, y: x.isclose(y)) immultop = None, imcmp = (lambda x, y: x.isclose(y))
) )
def deterministic_elemlist(self):
thelist = list()
group_dps_try(thelist, self.permgroup.identity, self.permgroupgens)
return thelist
def svwf_rep(self, lMax, *rep_gen_func_args, **rep_gen_func_kwargs): def svwf_rep(self, lMax, *rep_gen_func_args, **rep_gen_func_kwargs):
''' '''
This method generates full SVWF (reducible) representation of the group. This method generates full SVWF (reducible) representation of the group.
@ -85,7 +99,7 @@ class SVWFPointGroupInfo: # only for point groups, coz in svwf_rep() I use I_tyt
Generates a string with a chunk of C code with a definition of a qpms_finite_group_t instance. Generates a string with a chunk of C code with a definition of a qpms_finite_group_t instance.
See also groups.h. See also groups.h.
''' '''
permlist = list(self.permgroup.elements) # all elements ordered permlist = self.deterministic_elemlist()
order = len(permlist) order = len(permlist)
permindices = {perm: i for i, perm in enumerate(permlist)} # 'invert' permlist permindices = {perm: i for i, perm in enumerate(permlist)} # 'invert' permlist
identity = self.permgroup.identity identity = self.permgroup.identity