Skip to content

Commit

Permalink
perm_groups: __getitem__ added; generators stored as list
Browse files Browse the repository at this point in the history
  • Loading branch information
smichr committed Sep 11, 2012
1 parent 4bb77bf commit a8d78a8
Showing 1 changed file with 41 additions and 25 deletions.
66 changes: 41 additions & 25 deletions sympy/combinatorics/perm_groups.py
Expand Up @@ -56,9 +56,10 @@ class _JGraph(object):
i-th free position of jg
To a directed edge (i, j) between vertices i, j
it is associated the index of a permutation `g` satisfying
g[i] = j
g = jg[vertex[i].perm[vertex[i].index_neighbor[j]]]
= jg[vertex[j].perm[vertex[j].index_neighbor[i]]]
g[i] = j where
g = jg[vertex[i].perm[vertex[i].index_neighbor[j]]]
= jg[vertex[j].perm[vertex[j].index_neighbor[i]]]
cycle list of indices of vertices used to identify cycles
G Permutation group
Expand Down Expand Up @@ -321,24 +322,26 @@ class PermutationGroup(Basic):
>>> G = PermutationGroup([a, b])
>>> G
PermutationGroup([Permutation([0, 2, 1]), Permutation([1, 0, 2])])
>>> G[0]
Permutation([0, 2, 1])
References
==========
[1] Holt, D., Eick, B., O'Brien, E.
"Handbook of computational group theory"
"Handbook of Computational Group Theory"
[2] Seress, A.
"Permutation group algorithms"
"Permutation Group Algorithms"
[3] http://en.wikipedia.org/wiki/Schreier_vector
[4] http://en.wikipedia.org/wiki/Nielsen_transformation
#Product_replacement_algorithm
[5] Frank Celler, Charles R.Leedham-Green, Scott H.Murray,
Alice C.Niemeyer, and E.A.O'Brien. "Generating random
elements of a finite group"
Alice C.Niemeyer, and E.A.O'Brien. "Generating Random
Elements of a Finite Group"
[6] http://en.wikipedia.org/wiki/Block_%28permutation_group_theory%29
Expand All @@ -361,7 +364,7 @@ def __new__(cls, *args, **kw_args):
The default constructor.
"""
obj = Basic.__new__(cls, *args, **kw_args)
obj._generators = args[0]
obj._generators = list(args[0])
obj._order = None
obj._center = []
obj._is_abelian = None
Expand Down Expand Up @@ -392,6 +395,9 @@ def __new__(cls, *args, **kw_args):
obj._random_gens = []
return obj

def __getitem__(self, i):
return self._generators[i]

def __eq__(self, gr):
"""
test if two groups have the same elements
Expand Down Expand Up @@ -678,7 +684,9 @@ def baseswap(self, base, strong_gens, pos, randomized=False,\
>>> S = SymmetricGroup(4)
>>> S.schreier_sims()
>>> S.baseswap(S.base, S.strong_gens, 1, randomized=False)
([0, 2, 1], [Permutation([1, 2, 3, 0]), Permutation([1, 0, 2, 3]), Permutation([0, 1, 3, 2]), Permutation([0, 3, 1, 2]), Permutation([0, 3, 2, 1])])
([0, 2, 1], [Permutation([1, 2, 3, 0]), Permutation([1, 0, 2, 3]),
Permutation([0, 1, 3, 2]), Permutation([0, 3, 1, 2]),
Permutation([0, 3, 2, 1])])
>>> S.base
[0, 1, 2]
>>> _verify_bsgs(S, S.base, S.strong_gens)
Expand Down Expand Up @@ -813,7 +821,9 @@ def basic_stabilizers(self):
>>> A.base
[0, 1]
>>> A.basic_stabilizers
[PermutationGroup([Permutation([1, 2, 0, 3]), Permutation([0, 2, 3, 1]), Permutation([0, 3, 1, 2])]), PermutationGroup([Permutation([0, 2, 3, 1]), Permutation([0, 3, 1, 2])])]
[PermutationGroup([Permutation([1, 2, 0, 3]),
Permutation([0, 2, 3, 1]), Permutation([0, 3, 1, 2])]),
PermutationGroup([Permutation([0, 2, 3, 1]), Permutation([0, 3, 1, 2])])]
See Also
========
Expand Down Expand Up @@ -1077,7 +1087,9 @@ def coset_decomposition(self, g):
False
>>> c = Permutation([[0, 6], [1, 7], [2, 4], [3, 5]])
>>> G.coset_decomposition(c)
[[6, 4, 2, 0, 7, 5, 3, 1], [0, 4, 1, 5, 2, 6, 3, 7], [0, 1, 2, 3, 4, 5, 6, 7]]
[[6, 4, 2, 0, 7, 5, 3, 1],
[0, 4, 1, 5, 2, 6, 3, 7],
[0, 1, 2, 3, 4, 5, 6, 7]]
>>> G.has_element(c)
True
Expand Down Expand Up @@ -1343,7 +1355,8 @@ def generate(self, method="coset", af=False):
>>> b = Permutation([0, 2, 3, 1])
>>> g = PermutationGroup([a, b])
>>> list(g.generate(af=True))
[[0, 1, 2, 3], [0, 1, 3, 2], [0, 2, 3, 1], [0, 2, 1, 3], [0, 3, 2, 1], [0, 3, 1, 2]]
[[0, 1, 2, 3], [0, 1, 3, 2], [0, 2, 3, 1],
[0, 2, 1, 3], [0, 3, 2, 1], [0, 3, 1, 2]]
"""
if method == "coset":
Expand Down Expand Up @@ -1372,7 +1385,8 @@ def generate_dimino(self, af=False):
>>> b = Permutation([0, 2, 3, 1])
>>> g = PermutationGroup([a, b])
>>> list(g.generate_dimino(af=True))
[[0, 1, 2, 3], [0, 2, 1, 3], [0, 2, 3, 1], [0, 1, 3, 2], [0, 3, 2, 1], [0, 3, 1, 2]]
[[0, 1, 2, 3], [0, 2, 1, 3], [0, 2, 3, 1],
[0, 1, 3, 2], [0, 3, 2, 1], [0, 3, 1, 2]]
"""
idn = range(self.degree)
Expand Down Expand Up @@ -1425,7 +1439,8 @@ def generate_schreier_sims(self, af=False):
>>> b = Permutation([0, 2, 3, 1])
>>> g = PermutationGroup([a, b])
>>> list(g.generate_schreier_sims(af=True))
[[0, 1, 2, 3], [0, 1, 3, 2], [0, 2, 3, 1], [0, 2, 1, 3], [0, 3, 2, 1], [0, 3, 1, 2]]
[[0, 1, 2, 3], [0, 1, 3, 2], [0, 2, 3, 1],
[0, 2, 1, 3], [0, 3, 2, 1], [0, 3, 1, 2]]
"""
def get1(posmax):
Expand Down Expand Up @@ -1738,10 +1753,10 @@ def is_primitive(self, randomized=True):
@property
def is_solvable(self):
"""
Test if the group is solvable
Test if the group is solvable
`G` is solvable if its derived series terminates with the trivial
group ([1],p.29).
group ([1], p.29).
Examples
========
Expand Down Expand Up @@ -2829,7 +2844,7 @@ def schreier_sims_random(self, base=None, gens=None, consec_succ=10,\
strong_gens_distr[l].append(h)
stabs[l] = PermutationGroup(strong_gens_distr[l])
transversals[l] = dict(stabs[l].orbit_transversal(base[l],\
pairs=True))
pairs=True))
orbs[l] = transversals[l].keys()
c = 0
else:
Expand Down Expand Up @@ -3014,19 +3029,20 @@ def subgroup_search(self, prop, base=None, strong_gens=None, tests=None,\
A strong generating set for the supergroup.
tests
A list of callables of length equal to the length of ``base``.
These are used to rule out group elements by partial base images, so
that ``tests[l](g)`` returns False if the element ``g`` is known not
to satisfy prop base on where g sends the first ``l + 1`` base points.
``init_subgroup`` - if a subgroup of the saught group is known in
advance, it can be passed to the function as this parameter.
These are used to rule out group elements by partial base images,
so that ``tests[l](g)`` returns False if the element ``g`` is known
not to satisfy prop base on where g sends the first ``l + 1`` base
points. ``init_subgroup`` - if a subgroup of the saught group is
known in advance, it can be passed to the function as this
parameter.
Returns
=======
res
The subgroup of all elements satisfying ``prop``. The generating set
for this group is guaranteed to be a strong generating set relative to
the base ``base``.
The subgroup of all elements satisfying ``prop``. The generating
set for this group is guaranteed to be a strong generating set
relative to the base ``base``.
Examples
========
Expand Down

0 comments on commit a8d78a8

Please sign in to comment.