def __init__(self,
              parent,
              x=None,
              check=True,
              is_gen=False,
              construct=False):
     Polynomial_generic_dense.__init__(self, parent, x, check, is_gen)
    def __init__(self,
                 parent,
                 x=None,
                 check=True,
                 is_gen=False,
                 construct=False,
                 absprec=None):
        """
        TESTS:

        Check that :trac:`13620` has been fixed::

            sage: K = ZpFM(3)
            sage: R.<t> = K[]
            sage: R(R.zero())
            0
        """
        if x is None:
            Polynomial_generic_dense.__init__(self, parent, x, check, is_gen,
                                              construct)
            return
        R = parent.base_ring()
        if sage.rings.fraction_field_element.is_FractionFieldElement(x):
            if x.denominator() != 1:
                raise TypeError("denominator must be 1")
            else:
                x = x.numerator()
        if isinstance(x, Polynomial):
            if x.base_ring() is R:
                x = list(x.list())
            else:
                x = [R(a) for a in x.list()]
        elif isinstance(x, list):
            if check:
                x = [R(a) for a in x]
        elif isinstance(x, dict):
            if check:
                m = infinity
                zero = R(0)
                n = max(x) if x else 0
                v = [zero] * (n + 1)
                for i, z in x.items():
                    v[i] = R(z)
                    m = min(m, v[i].precision_absolute())
                x = v
            else:
                m = sage.rings.padics.misc.min(a.precision_absolute()
                                               for a in x.values())
            if absprec is not None:
                m = min(m, absprec)
            Polynomial_generic_dense.__init__(self, parent, x, absprec=m)
            return
        elif isinstance(x, pari_gen):
            x = [R(w) for w in x.list()]
        else:
            x = [R(x)]
        if absprec is None:
            absprec = infinity
        m = min([a.precision_absolute() for a in x] + [absprec])
        Polynomial_generic_dense.__init__(self, parent, x, absprec=m)
    def __init__(self,
                 parent,
                 x=None,
                 check=True,
                 is_gen=False,
                 construct=False,
                 absprec=None):
        """
        Initialization function for the class  Polynomial_padic_flat.
        """

        if x is None:
            Polynomial_generic_dense.__init__(self,
                                              parent,
                                              x=None,
                                              is_gen=is_gen)
            return
        R = parent.base_ring()
        if sage.rings.fraction_field_element.is_FractionFieldElement(x):
            if x.denominator() != 1:
                raise TypeError, "denominator must be 1"
            else:
                x = x.numerator()
        if isinstance(x, Polynomial):
            if x.base_ring() is R:
                x = list(x.list())
            else:
                x = [R(a) for a in x.list()]
        elif isinstance(x, list):
            if check:
                x = [R(a) for a in x]
        elif isinstance(x, dict):
            if check:
                m = infinity
                zero = R(0)
                n = max(x.keys())
                v = [zero for _ in xrange(n + 1)]
                for i, z in x.iteritems():
                    v[i] = R(z)
                    m = min(m, v[i].precision_absolute())
                x = v
            else:
                m = sage.rings.padics.misc.min(a.precision_absolute()
                                               for a in x.values())
            if not absprec is None:
                m = min(m, absprec)
            Polynomial_generic_dense.__init__(self, parent, x, absprec=m)
            return
        elif isinstance(x, pari_gen):
            x = [R(w) for w in x.list()]
        else:
            x = [R(x)]
        if absprec is None:
            absprec = infinity
        m = min([a.precision_absolute() for a in x] + [absprec])
        Polynomial_generic_dense.__init__(self, parent, x, absprec=m)
    def __init__(self, parent, x=None, check=True, is_gen=False, construct=False, absprec=None):
        """
        TESTS:

        Check that :trac:`13620` has been fixed::

            sage: K = ZpFM(3)
            sage: R.<t> = K[]
            sage: R(R.zero())
            0

        """
        if x is None:
            Polynomial_generic_dense.__init__(self, parent, x, check, is_gen, construct)
            return
        R = parent.base_ring()
        if sage.rings.fraction_field_element.is_FractionFieldElement(x):
            if x.denominator() != 1:
                raise TypeError("denominator must be 1")
            else:
                x = x.numerator()
        if isinstance(x, Polynomial):
            if x.base_ring() is R:
                x = list(x.list())
            else:
                x = [R(a) for a in x.list()]
        elif isinstance(x, list):
            if check:
                x = [R(a) for a in x]
        elif isinstance(x, dict):
            if check:
                m = infinity
                zero = R(0)
                n = max(x.keys()) if x else 0
                v = [zero] * (n + 1)
                for i, z in six.iteritems(x):
                    v[i] = R(z)
                    m = min(m, v[i].precision_absolute())
                x = v
            else:
                m = sage.rings.padics.misc.min(a.precision_absolute() for a in x.values())
            if not absprec is None:
                m = min(m, absprec)
            Polynomial_generic_dense.__init__(self, parent, x, absprec = m)
            return
        elif isinstance(x, pari_gen):
            x = [R(w) for w in x.list()]
        else:
            x = [R(x)]
        if absprec is None:
            absprec = infinity
        m = min([a.precision_absolute() for a in x] + [absprec])
        Polynomial_generic_dense.__init__(self, parent, x, absprec = m)
 def __init__(self, parent, x=None, check=True, is_gen=False, construct=False, absprec=None):
     """
     Initialization function for the class  Polynomial_padic_flat.
     """
     
     if x is None:
         Polynomial_generic_dense.__init__(self, parent, x = None, is_gen = is_gen)
         return
     R = parent.base_ring()
     if sage.rings.fraction_field_element.is_FractionFieldElement(x):
         if x.denominator() != 1:
             raise TypeError, "denominator must be 1"
         else:
             x = x.numerator()
     if isinstance(x, Polynomial):
         if x.base_ring() is R:
             x = list(x.list())
         else:
             x = [R(a) for a in x.list()]
     elif isinstance(x, list):
         if check:
             x = [R(a) for a in x]
     elif isinstance(x, dict):
         if check:
             m = infinity
             zero = R(0)
             n = max(x.keys())
             v = [zero for _ in xrange(n+1)]
             for i, z in x.iteritems():
                 v[i] = R(z)
                 m = min(m, v[i].precision_absolute())
             x = v
         else:
             m = sage.rings.padics.misc.min(a.precision_absolute() for a in x.values())
         if not absprec is None:
             m = min(m, absprec)
         Polynomial_generic_dense.__init__(self, parent, x, absprec = m)
         return
     elif isinstance(x, pari_gen):
         x = [R(w) for w in x.Vecrev()]
     else:
         x = [R(x)]
     if absprec is None:
         absprec = infinity
     m = min([a.precision_absolute() for a in x] + [absprec])
     Polynomial_generic_dense.__init__(self, parent, x, absprec = m)
 def __init__(self, parent, x=None, check=True, is_gen = False, construct=False):
     Polynomial_generic_dense.__init__(self, parent, x, check, is_gen)
Exemple #7
0
 def _mul_(self,other):
     res = Polynomial_generic_dense._mul_(self,other)
     Approximation.__init__(res,res.parent())
     res._expected_degree = res.degree()
     res._length = res._expected_degree + 1
     return res
Exemple #8
0
 def __init__(self, parent, x, check=True, is_gen=False, construct=False):
     Polynomial_generic_dense.__init__(self, parent, x, check=check, is_gen=is_gen, construct=construct)
     Approximation.__init__(self,parent)
     self._expected_degree = self.degree()
     self._length = self._expected_degree + 1