1 | initial version |

The invariants as returned are in fact correct if you understand them to be the elementary divisors. Were you expecting them to be the concatenation of the invariants of the Sylow subgroups? The elementary divisor interpretation is more canonical.

In any case, the baroque print representation of elements in the class group mean that most of the group functionality (which would call gap via string interfaces) chokes, because the print names of the elements are supposed to be used as identifiers in gap.

The trick is to build an isomorphic (abstract) group and define an isomorphism. It would be nice if it were automated, but once you get through basics it's not that bad:

```
sage: K.<a>=NumberField(x^2+26)
sage: C=K.class_group()
sage: G=AbelianGroup(C.invariants())
sage: GtoC=G.Hom(C)(lambda a: prod([b^e for e,b in zip(a.list(),C.gens())]))
sage: G.0
f
sage: GtoC(G.0)
Fractional ideal class (5, a + 2)
```

Many group operations (such as "subgroups") do work on G. Computing Sylow subgroups in finite abelian groups is easy enough to do by hand:

```
sage: P3=G.subgroup([g^c for g in G.gens()])
sage: N=G.order()
sage: c=(N // 3^(N.valuation(3)))
sage: P3=G.subgroup([g^c for g in G.gens()])
```

If you prefer, you could also ask for `G=AdditiveAbelianGroups(...)`

, which would give you a structure that concentrates more on the Z-module structure of G and misses some of the gap-related functionality.

A lot of these things would be nice to get a little easier. Especially the construction of G and GtoC should perhaps be automated, since the group returned by classgroup is a little hobbled (or perhaps that should be fixed, which would probably be quite a bit of work)

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.