Opened 13 years ago

Closed 10 years ago

# implement more functionality for class groups of number fields

Reported by: Owned by: was davidloeffler major sage-duplicate/invalid/wontfix number fields John Cremona N/A

### Description

There are some feature requests in this email.

```On 11/1/07, Utpal Sarkar wrote:
> I'm doing some simple things with class groups, and some things don't
> work as expected.
> Let G be a class group of a number field.

sage: K.<a> = NumberField(x^2 + 23)
sage: G = K.class_group(); G
Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23

> I am interested in obtaining
> the actual ideal classes
> (is there an easy direct way? list(G) returns abstract elements. Is it
> possible to obtain a map from the class group to the ideal group,
> mapping class group elements to representatives?)

This is not implemented yet (the function list is just
something implemented in the base abstract abelian
group class, which is inherited -- it doesn't do anything
useful in this case, really.)   Class groups were only
added to sage very recently, and aren't fully implemented.
Adding code to enumerate all elements will show up in Sage
soon, but it will take some work.

> Since generators of G can be obtained as ideal classes, to obtain all
> of them you just have to multiply powers of the generators, and for
> that it would be useful to know the orders of the generators.
> When I call
> (G.0).order()
> it shows an error message saying that it is not implemented (which
> seems strange).

It isn't implemented.  You could implement a dumb order
function though:

sage: K.<a> = NumberField(x^2 + 23)
sage: G = K.class_group(); G
Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23
sage: G.gens()
[Fractional ideal class (2, 1/2*a - 1/2)]
sage: a = G.0
sage: def myorder(I):
...       n = 1
...       J = I
...       while J != 1:
...           J = J * I
...           n += 1
...       return n
sage: myorder(a)
3

--

I don't recommend doing this -- it's much better to understand
how fractional ideals, etc. are represented using the PARI
C library in Sage, then use a call to PARI to determine the
order of the fractional ideal class.   This is what I'll do
when I implement this in the Sage library.

>  I tried to work around this by generating the
> subgroups of G generated by these generators of G in turn to obtain
> their orders, but when I say
> G.subgroup([G.0])
> or
> G.subgroup(G.gens())
> an error results, saying that the elements passed don't belong to G.

That's because creating subgroups of ideal class groups is not implemented.  Sage should produce a NotImplementedError in this case too.

-- William}}}
```

### comment:1 Changed 13 years ago by was

NOTE: The AbelianGroup? class needs to be refactored, so there is an abstract base class, with lots of NotImplementedErrors?, then AbelianGroup_that_David_implemented derives from that as does ClassGroup?. Same with elements. This will avoid a lot of the confusion in evidence in the above email.

### comment:2 Changed 13 years ago by ncalexan

```sage: K.<a> = NumberField(x^3 + 1838)
sage: C = K.class_group(); C
Class group of order 27 with structure C9 x C3 of Number Field in a with defining polynomial x^3 + 1838
sage: C.gens()
[Fractional ideal class (50, a - 8), Fractional ideal class (26, a - 2)]
sage: I = C.gen(0)
sage: I^-1
---------------------------------------------------------------------------
<type 'exceptions.AttributeError'>        Traceback (most recent call last)

/Users/ncalexan/sage-2.7.2/devel/sage-bugday2/<ipython console> in <module>()

/Users/ncalexan/sage-2.7.2/devel/sage-bugday2/element.pyx in sage.structure.element.MonoidElement.__pow__()

/Users/ncalexan/sage-2.7.2/devel/sage-bugday2/element.pyx in sage.structure.element.generic_power_c()

/Users/ncalexan/sage-2.7.2/devel/sage-bugday2/element.pyx in sage.structure.element.MultiplicativeGroupElement.__invert__()

/Users/ncalexan/sage-2.7.2/devel/sage-bugday2/element.pyx in sage.structure.element.MultiplicativeGroupElement.__div__()

/Users/ncalexan/sage-2.7.2/devel/sage-bugday2/coerce.pyx in sage.structure.coerce.CoercionModel_cache_maps.bin_op_c()

/Users/ncalexan/sage-2.7.2/devel/sage-bugday2/element.pyx in sage.structure.element.MultiplicativeGroupElement.__div__()

/Users/ncalexan/sage-2.7.2/devel/sage-bugday2/element.pyx in sage.structure.element.MultiplicativeGroupElement._div_()

/Users/ncalexan/sage-2.7.2/devel/sage-bugday2/element.pyx in sage.structure.element.MultiplicativeGroupElement._div_c_impl()

<type 'exceptions.AttributeError'>: 'ClassGroup' object has no attribute 'fraction_field'
```

### comment:3 Changed 12 years ago by davidloeffler

• Component changed from number theory to number fields
• Owner changed from was to davidloeffler

### comment:4 Changed 11 years ago by jdemeyer

• Milestone changed from sage-4.6 to sage-duplicate/invalid/wontfix
• Report Upstream set to N/A
• Status changed from new to needs_review

The following works for me in sage-4.6.alpha3, so needs_review as "already fixed".

```sage: K.<a> = NumberField(x^2 + 23)
sage: G = K.class_group(); G
Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23
sage: (G.0).order()
3
sage: list(G)
[Trivial principal fractional ideal class, Fractional ideal class (2, 1/2*a - 1/2), Fractional ideal class (2, 1/2*a + 1/2)]
```

### comment:5 Changed 10 years ago by cremona

• Status changed from needs_review to positive_review

I agree with Jeroen, and Nick A's example also now works, so I have made the "positive review" and the next release manager can mark it as fixed.

### comment:6 Changed 10 years ago by jdemeyer

• Merged in set to sage-4.6.1.alpha0
• Resolution set to duplicate
• Status changed from positive_review to closed

### comment:7 Changed 10 years ago by jdemeyer

• Reviewers set to John Cremona

### comment:8 Changed 10 years ago by jdemeyer

• Merged in sage-4.6.1.alpha0 deleted
Note: See TracTickets for help on using tickets.