Ask Your Question

Revision history [back]

You just have to do:

sage: K.ideals_of_bdd_norm(5)
{1: [Fractional ideal (1)],
 2: [Fractional ideal (a + 1)],
 3: [],
 4: [Fractional ideal (2)],
 5: [Fractional ideal (2*a + 1), Fractional ideal (-a - 2)]}

What you get is a Python dictionary, whose keys are the norms, and the values are Python lists of the ideals with given norm.

For example:

sage: K.ideals_of_bdd_norm(5)[3]
[]

is an empty list since there is no ideal with norm 3

sage: K.ideals_of_bdd_norm(5)[5]
[Fractional ideal (2*a + 1), Fractional ideal (-a - 2)]

is a list with 2 elements: you can access them as follows:

sage: K.ideals_of_bdd_norm(5)[5][0]
Fractional ideal (2*a + 1)
sage: K.ideals_of_bdd_norm(5)[5][1]
Fractional ideal (-a - 2)

Now, if you want all those ideals without caring about their norm, you can do:

sage: d = K.ideals_of_bdd_norm(5)
sage: [f for i in d for f in d[i]]
[Fractional ideal (1),
 Fractional ideal (a + 1),
 Fractional ideal (2),
 Fractional ideal (2*a + 1),
 Fractional ideal (-a - 2)]

or

sage: flatten(d.values())
[Fractional ideal (1),
 Fractional ideal (a + 1),
 Fractional ideal (2),
 Fractional ideal (2*a + 1),
 Fractional ideal (-a - 2)]