Hi there,

On Dec 3, 5:08 pm, Florent Hivert <florent.hiv...@univ-rouen.fr>
wrote:
> However, I thing it should be a method of the group:
>    G.conjugacy_class(g).

that was my original idea, to keep it close to GAP original
definition.

> Or even of the element itself since it knows G as it's parent:
>    g.conjugacy_class()
>
> def conjugacy_class(self):
>      GG = self.parent()._gap_()
>      gg = self._gap_()
>      cc = GG.ConjugacyClass(gg).AsList().sage()
>      return Set([G(x) for x in cc])

This also makes sense. I don't really know which choice would be
better. Maybe having both, doing something like

def conjugacy_class(self):
    G = self.parent()
    return G.conjugacy_class(g)

does that sound reasonable or would it be better to stick just to one
of them?

> And finally for those groups who are not known to gap, the fallback
> (sage-only) method should be in the category FiniteGroups to be inherited by
> any group.

I hadn't thought of that. Since all the groups I used are defined as
permutation groups I never ran into trouble, but now that you mention
it I see that GAP function doesn't work for matrix groups:

sage: F = GF(5)
sage: gens = [matrix(F,2,[1,2, -1, 1]), matrix(F,2, [1,1, 0,1])]
sage: G = MatrixGroup(gens)
sage: g = G(matrix(F,2,[1,2, -1, 1]))
sage: conjugacy_class_gap(g,G)
Traceback (most recent call last):
...
NotImplementedError


So I guess the right thing to do is something like

sage: def conjugacy_class(g,G):
...       try:                # Try to use GAP function if defined
...           GG = G._gap_()
...           gg = g._gap_()
...           cc = GG.ConjugacyClass(gg).AsList().sage()
...           return Set([G(x) for x in cc])
...       except NotImplementedError:    # If GAP doesn´t work, use
naive method
...           return Set([x*g*x^(-1) for x in G])

maybe with some added checks to deal with abelian groups (trivial
conjugacy classes) and not using the naive method on infinite groups.

In which file should the code be included?
$SAGE_ROOT/devel/sage/sage/generic.py or somewhere else?

Cheers
Javier

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

Reply via email to