Пример #1
0
    def __init__(self, field, prec, log_radii, names, order, integral=False):
        """
        Initialize the Tate algebra

        TESTS::

            sage: A.<x,y> = TateAlgebra(Zp(2), log_radii=1)
            sage: TestSuite(A).run()

        We check that univariate Tate algebras work correctly::

            sage: B.<t> = TateAlgebra(Zp(3))

        """
        from sage.misc.latex import latex_variable_name
        from sage.rings.polynomial.polynomial_ring_constructor import _multi_variate
        self.element_class = TateAlgebraElement
        self._field = field
        self._cap = prec
        self._log_radii = ETuple(log_radii)  # TODO: allow log_radii in QQ
        self._names = names
        self._latex_names = [latex_variable_name(var) for var in names]
        uniformizer = field.change(print_mode='terse',
                                   show_prec=False).uniformizer()
        self._uniformizer_repr = uniformizer._repr_()
        self._uniformizer_latex = uniformizer._latex_()
        self._ngens = len(names)
        self._order = order
        self._integral = integral
        if integral:
            base = field.integer_ring()
        else:
            base = field
        CommutativeAlgebra.__init__(self,
                                    base,
                                    names,
                                    category=CommutativeAlgebras(base))
        self._polynomial_ring = _multi_variate(field, names, order=order)
        one = field(1)
        self._parent_terms = TateTermMonoid(self)
        self._oneterm = self._parent_terms(one, ETuple([0] * self._ngens))
        if integral:
            # This needs to be update if log_radii are allowed to be non-integral
            self._gens = [
                self((one << log_radii[i]) * self._polynomial_ring.gen(i))
                for i in range(self._ngens)
            ]
            self._integer_ring = self
        else:
            self._gens = [self(g) for g in self._polynomial_ring.gens()]
            self._integer_ring = TateAlgebra_generic(field,
                                                     prec,
                                                     log_radii,
                                                     names,
                                                     order,
                                                     integral=True)
            self._integer_ring._rational_ring = self._rational_ring = self
Пример #2
0
    def monomial(self, *args):
        r"""
        Return the monomial whose exponents are given in argument.

        EXAMPLES::

            sage: L = LaurentPolynomialRing(QQ, 'x', 2)
            sage: L.monomial(-3, 5)
            x0^-3*x1^5
            sage: L.monomial(1, 1)
            x0*x1
            sage: L.monomial(0, 0)
            1
            sage: L.monomial(-2, -3)
            x0^-2*x1^-3

            sage: x0, x1 = L.gens()
            sage: L.monomial(-1, 2) == x0^-1 * x1^2
            True

            sage: L.monomial(1, 2, 3)
            Traceback (most recent call last):
            ...
            TypeError: tuple key must have same length as ngens
        """
        element_class = LaurentPolynomial_mpair

        if len(args) != self.ngens():
            raise TypeError("tuple key must have same length as ngens")

        from sage.rings.polynomial.polydict import ETuple
        m = ETuple(args, int(self.ngens()))
        return element_class(self, self.polynomial_ring().one(), m)
Пример #3
0
    def monomial_lcm(self, f, g):
        """
        LCM for monomials. Coefficients are ignored.

        INPUT:


        -  ``f`` - monomial

        -  ``g`` - monomial


        EXAMPLE::

            sage: from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_polydict_domain
            sage: P.<x,y,z>=MPolynomialRing_polydict_domain(QQ,3, order='degrevlex')
            sage: P.monomial_lcm(3/2*x*y,x)
            x*y

        TESTS::

            sage: from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_polydict_domain
            sage: R.<x,y,z>=MPolynomialRing_polydict_domain(QQ,3, order='degrevlex')
            sage: P.<x,y,z>=MPolynomialRing_polydict_domain(QQ,3, order='degrevlex')
            sage: P.monomial_lcm(x*y,R.gen())
            x*y

        ::

            sage: P.monomial_lcm(P(3/2),P(2/3))
            1

        ::

            sage: P.monomial_lcm(x,P(1))
            x
        """
        one = self.base_ring()(1)

        f=f.dict().keys()[0]
        g=g.dict().keys()[0]


        length = len(f)

        res = {}

        for i in f.common_nonzero_positions(g):
            res[i] = max([f[i],g[i]])

        res =  self(PolyDict({ETuple(res,length):one},\
                            force_int_exponents=False,force_etuples=False))
        return res
Пример #4
0
    def monomial_all_divisors(self, t):
        r"""
        Return a list of all monomials that divide ``t``, coefficients are
        ignored.

        INPUT:

        -  ``t`` - a monomial.

        OUTPUT: a list of monomials.

        EXAMPLES::

            sage: from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_polydict_domain
            sage: P.<x,y,z> = MPolynomialRing_polydict_domain(QQ,3, order='degrevlex')
            sage: P.monomial_all_divisors(x^2*z^3)
            [x, x^2, z, x*z, x^2*z, z^2, x*z^2, x^2*z^2, z^3, x*z^3, x^2*z^3]

        ALGORITHM: addwithcarry idea by Toon Segers
        """
        def addwithcarry(tempvector, maxvector, pos):
            if tempvector[pos] < maxvector[pos]:
                tempvector[pos] += 1
            else:
                tempvector[pos] = 0
                tempvector = addwithcarry(tempvector, maxvector, pos + 1)
            return tempvector

        if not t.is_monomial():
            raise TypeError("only monomials are supported")

        R = self
        one = self.base_ring().one()
        M = list()

        v, = t.dict()
        maxvector = list(v)

        tempvector = [
            0,
        ] * len(maxvector)

        pos = 0

        while tempvector != maxvector:
            tempvector = addwithcarry(list(tempvector), maxvector, pos)
            M.append(
                R(
                    PolyDict({ETuple(tempvector): one},
                             force_int_exponents=False,
                             force_etuples=False)))
        return M
Пример #5
0
    def __getitem__(self, a):
        r"""
        Extract Fourier coefficients.

        The exponent should be hermitian and (in the case of trivial character) have integral diagonal and off-diagonal entries contained in the dual lattice O_K'.

        EXAMPLES::

            sage: from weilrep import *
            sage: K.<i> = NumberField(x*x + 1)
            sage: h = HermitianModularForms(K)
            sage: f = h.eisenstein_series(4, 5)
            sage: A = matrix([[1, 1/2 + i/2], [1/2 - i/2, 1]])
            sage: f[A]
            2880
        """
        try:
            a = a.list()
        except AttributeError:
            pass
        a, b, _, d = a
        S = self.gram_matrix()
        try:
            b, c = b.parts()
            if S[0, 1]:
                b, c = b + b, b + c * (2 * S[1, 1] - 1)
            else:
                b, c = b + b, c * S[1, 1]
        except AttributeError:
            if S[0, 1]:
                b, c = b + b, b
            else:
                b, c = b + b, 0
        f = self.true_fourier_expansion()
        s = self.scale()
        try:
            return f[Integer((a + d) * s)][Integer(
                (a - d) * s)].dict()[ETuple([Integer(b * s),
                                             Integer(c * s)])]
        except KeyError:
            return 0
Пример #6
0
    def __init__(self, A):
        r"""
        Initialize the Tate term monoid

        INPUT:

        - ``A`` -- a Tate algebra

        EXAMPLES::

            sage: R = pAdicRing(2, 10)
            sage: A.<x,y> = TateAlgebra(R, log_radii=1)
            sage: T = A.monoid_of_terms(); T
            Monoid of terms in x (val >= -1), y (val >= -1) over 2-adic Field with capped relative precision 10

        TESTS::

            sage: A.<x,y> = TateAlgebra(Zp(2), log_radii=1)
            sage: T = A.monoid_of_terms()
            sage: TestSuite(T).run()

        """
        # This function is not exposed to the user
        # so we do not check the inputs
        names = A.variable_names()
        Monoid_class.__init__(self, names)
        self._base = A.base_ring()
        self._field = A._field
        self._names = names
        self._latex_names = A._latex_names
        self._ngens = len(names)
        self._log_radii = ETuple(A.log_radii())
        self._order = A.term_order()
        self._sortkey = self._order.sortkey
        self._integral = A._integral
        self._parent_algebra = A
Пример #7
0
    def _element_constructor_(self, x, mon=None):
        """
        EXAMPLES::

            sage: L = LaurentPolynomialRing(QQ,2,'x')
            sage: L(1/2)
            1/2

            sage: M = LaurentPolynomialRing(QQ, 'x, y')
            sage: var('x, y')
            (x, y)
            sage: M(x/y + 3/x)
            x*y^-1 + 3*x^-1

        ::

            sage: M(exp(x))
            Traceback (most recent call last):
            ...
            TypeError: unable to convert e^x to a rational

        ::

            sage: L.<a, b, c, d> = LaurentPolynomialRing(QQ)
            sage: M = LaurentPolynomialRing(QQ, 'c, d')
            sage: Mc, Md = M.gens()
            sage: N = LaurentPolynomialRing(M, 'a, b')
            sage: Na, Nb = N.gens()
            sage: M(c/d)
            c*d^-1
            sage: N(a*b/c/d)
            (c^-1*d^-1)*a*b
            sage: N(c/d)
            c*d^-1
            sage: L(Mc)
            c
            sage: L(Nb)
            b

            sage: M(L(0))
            0
            sage: N(L(0))
            0
            sage: L(M(0))
            0
            sage: L(N(0))
            0

            sage: U = LaurentPolynomialRing(QQ, 'a')
            sage: Ua = U.gen()
            sage: V = LaurentPolynomialRing(QQ, 'c')
            sage: Vc = V.gen()
            sage: L(Ua)
            a
            sage: L(Vc)
            c
            sage: N(Ua)
            a
            sage: M(Vc)
            c

            sage: P = LaurentPolynomialRing(QQ, 'a, b')
            sage: Q = LaurentPolynomialRing(P, 'c, d')
            sage: Q(P.0)
            a

        ::

            sage: A.<a> = LaurentPolynomialRing(QQ)
            sage: B.<b> = LaurentPolynomialRing(A)
            sage: C = LaurentPolynomialRing(QQ, 'a, b')
            sage: C(B({1: a}))
            a*b
            sage: D.<d, e> = LaurentPolynomialRing(B)
            sage: F.<f, g> = LaurentPolynomialRing(D)
            sage: D(F(d*e))
            d*e

        ::

            sage: from sage.rings.polynomial.polydict import ETuple
            sage: R.<x,y,z> = LaurentPolynomialRing(QQ)
            sage: mon = ETuple({}, int(3))
            sage: P = R.polynomial_ring()
            sage: R(sum(P.gens()), mon)
            x + y + z
            sage: R(sum(P.gens()), (-1,-1,-1))
            y^-1*z^-1 + x^-1*z^-1 + x^-1*y^-1
        """
        from sage.symbolic.expression import Expression
        element_class = LaurentPolynomial_mpair

        if mon is not None:
            return element_class(self, x, mon)

        P = parent(x)
        if P is self.polynomial_ring():
            from sage.rings.polynomial.polydict import ETuple
            return element_class(self, x, mon=ETuple({}, int(self.ngens())))

        elif isinstance(x, Expression):
            return x.laurent_polynomial(ring=self)

        elif isinstance(
                x, (LaurentPolynomial_univariate, LaurentPolynomial_mpair)):
            if self.variable_names() == P.variable_names():
                # No special processing needed here;
                #   handled by LaurentPolynomial_mpair.__init__
                pass
            elif set(self.variable_names()) & set(P.variable_names()):
                if isinstance(x, LaurentPolynomial_univariate):
                    d = {(k, ): v for k, v in iteritems(x.dict())}
                else:
                    d = x.dict()
                x = _split_laurent_polynomial_dict_(self, P, d)
            elif self.base_ring().has_coerce_map_from(P):
                from sage.rings.polynomial.polydict import ETuple
                mz = ETuple({}, int(self.ngens()))
                return element_class(self, {mz: self.base_ring()(x)}, mz)
            elif x.is_constant() and self.has_coerce_map_from(P.base_ring()):
                return self(x.constant_coefficient())
            elif len(self.variable_names()) == len(P.variable_names()):
                x = x.dict()

        return element_class(self, x)