def __init__(self, parent, x, bits=None, nterms=None): """ EXAMPLES:: sage: sage.rings.contfrac.ContinuedFraction(CFF,[1,2,3,4,1,2]) [1, 2, 3, 4, 1, 2] sage: sage.rings.contfrac.ContinuedFraction(CFF,[1,2,3,4,-1,2]) Traceback (most recent call last): ... ValueError: each entry except the first must be positive """ FieldElement.__init__(self, parent) if isinstance(x, ContinuedFraction): self._x = list(x._x) elif isinstance(x, (list, tuple)): x = [ZZ(a) for a in x] for i in range(1, len(x)): if x[i] <= 0: raise ValueError, "each entry except the first must be positive" self._x = list(x) else: self._x = [ ZZ(a) for a in continued_fraction_list(x, bits=bits, nterms=nterms) ]
def selmer_group(self, S, m, proof=True, orders=False): r""" Compute the group `\QQ(S,m)`. INPUT: - ``S`` -- a set of primes - ``m`` -- a positive integer - ``proof`` -- ignored - ``orders`` (default False) -- if True, output two lists, the generators and their orders OUTPUT: A list of generators of `\QQ(S,m)` (and, optionally, their orders in `\QQ^\times/(\QQ^\times)^m`). This is the subgroup of `\QQ^\times/(\QQ^\times)^m` consisting of elements `a` such that the valuation of `a` is divisible by `m` at all primes not in `S`. It is equal to the group of `S`-units modulo `m`-th powers. The group `\QQ(S,m)` contains the subgroup of those `a` such that `\QQ(\sqrt[m]{a})/\QQ` is unramified at all primes of `\QQ` outside of `S`, but may contain it properly when not all primes dividing `m` are in `S`. EXAMPLES:: sage: QQ.selmer_group((), 2) [-1] sage: QQ.selmer_group((3,), 2) [-1, 3] sage: QQ.selmer_group((5,), 2) [-1, 5] The previous examples show that the group generated by the output may be strictly larger than the 'true' Selmer group of elements giving extensions unramified outside `S`. When `m` is even, `-1` is a generator of order `2`:: sage: QQ.selmer_group((2,3,5,7,), 2, orders=True) ([-1, 2, 3, 5, 7], [2, 2, 2, 2, 2]) sage: QQ.selmer_group((2,3,5,7,), 3, orders=True) ([2, 3, 5, 7], [3, 3, 3, 3]) """ gens = list(S) ords = [ZZ(m)] * len(S) if m % 2 == 0: gens = [ZZ(-1)] + gens ords = [ZZ(2)] + ords if orders: return gens, ords else: return gens
def characteristic(self): """ Return 0, since the continued fraction field has characteristic 0. EXAMPLES:: sage: c = CFF.characteristic(); c 0 sage: parent(c) Integer Ring """ return ZZ(0)
def primes_of_bounded_norm_iter(self, B): r""" Iterator yielding all primes less than or equal to `B`. INPUT: - ``B`` -- a positive integer; upper bound on the primes generated. OUTPUT: An iterator over all integer primes less than or equal to `B`. .. note:: This function exists for compatibility with the related number field method, though it returns prime integers, not ideals. EXAMPLES:: sage: it = QQ.primes_of_bounded_norm_iter(10) sage: list(it) [2, 3, 5, 7] sage: list(QQ.primes_of_bounded_norm_iter(1)) [] """ try: B = ZZ(B.ceil()) except (TypeError, AttributeError): raise TypeError("%s is not valid bound on prime ideals" % B) if B < 2: raise StopIteration from sage.rings.arith import primes for p in primes(B + 1): yield p