On Oct 2, 1:55 pm, Rafael <rvf0...@gmail.com> wrote:
> Rafael <rvf0...@gmail.com> writes:
> > Hi to all,
>
> > Let us say that "reg" is a permutation group. I want to find the
> > elements of reg that send 12 to 1. Is there a better way to do that (in
> > one step, say) than:
>
> > sage: def f(x): return x(12)==1
> > ....:
> > sage: filter(f,reg.list())
> > [(1,12)(2,5)(3,4)(6,7)(8,11)(9,10)]

Python's list comprehension terminology:

[x for x in reg if x(12) == 1]

or the direct analogy of GAP's command:

filter(lambda x: x(12) ==1, reg)

However, this is a little bit like doing linear algebra over finite
fields by enumerating all vectors. By using proper group theoretic
concepts and algorithms you can handle problems of a different order
of magnitude.

If you really want an explicit list of all the permutations this
approach is of course fine, but you can describe (and compute with)
the set you want much more efficiently by representing it as a coset
of a point stabilizer.

As an experiment I looked how difficult it is to implement the more
efficient approach in sage. It requires a bit of work, but it doesn't
seem outrageous. Each step can be accomplished in one line.

assert 1 in reg.orbit(12)
H = reg.stabilizer(12)

#the following finds a particular solution by randomly trying.
#expected number of tries: length of reg.orbit(12)
#does someone know a nicer way to do this?
#using an iterator to select a single element seems a bit unnatural

import itertools
g = (x for x in (reg.random_element() for i in itertools.repeat(None))
if x(12) == 1).next()

#in order to answer your original question, we lose all efficiency
gained:

[h*g for h in H]

This seems a bit inconsistent in sage: (h*g)(x) = g(h(x)). Looks like
the person implementing permutation groups in sage thought
permutations act on the right, but the functional notation suggest an
action on the left.

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to