def ideals_of_norm(v): """ INPUT: - `v` -- integer >= 2, or list of integers >= 2 OUTPUT: - list of ideals of all ideals that have norm in v that is >= 2. EXAMPLES:: sage: sage.modular.hilbert.sqrt5_tables.ideals_of_norm(4) [Fractional ideal (2)] sage: sage.modular.hilbert.sqrt5_tables.ideals_of_norm([9,11]) [Fractional ideal (3), Fractional ideal (-3*a + 1), Fractional ideal (-3*a + 2)] sage: sage.modular.hilbert.sqrt5_tables.ideals_of_norm([4*5]) [Fractional ideal (-4*a + 2)] sage: sage.modular.hilbert.sqrt5_tables.ideals_of_norm(4*5) [Fractional ideal (-4*a + 2)] """ try: v = list(v) except TypeError: v = [Integer(v)] z = F.ideals_of_bdd_norm(max(v)) return sum([z[n] for n in v if n > 1], [])
def ideals_of_bounded_norm(B): r""" Return all ideals in the ring of integers of Q(sqrt(5)) with norm bigger than 1 and <= B. INPUT: - `B` -- positive integer OUTPUT: - list of ideals EXAMPLES:: sage: v = sage.modular.hilbert.sqrt5_tables.ideals_of_bounded_norm(11); v [Fractional ideal (2), Fractional ideal (-2*a + 1), Fractional ideal (3), Fractional ideal (-3*a + 1), Fractional ideal (-3*a + 2)] sage: [I.norm() for I in v] [4, 5, 9, 11, 11] """ return sum([v for n, v in F.ideals_of_bdd_norm(B).iteritems() if n != 1], [])