Exemplo n.º 1
0
 def __init__(self, parent, x, prec=None, *args, **kwargs):
     approxring = parent.approximation()
     if isinstance(x, QQpApprox_element) or isinstance(x, LazyApproximation_padics):
         approximation = x
     elif x in QQ:
         if x.valuation(parent._p) < 0:
             raise ValueError("%s is not in Z_%s" % (x, parent._p))
         approximation = QQpApprox_element(approxring, x, 0)
     else:
         raise TypeError
     RingElement_inexact.__init__(self, parent, approximation, prec, *args, **kwargs)
Exemplo n.º 2
0
 def __init__(self, parent, x, prec=None, group=None, *args, **kwargs):
     from ZZp_element import ZZp_element
     approxring = parent.approximation()
     if isinstance(x, ZZp_element):
         approximation = x._approximation
         prec = x._precision.flat_below()
     elif x in QQ:
         approximation = QQpApprox_element(approxring, x, 0)
     else:
         approximation = x
     RingElement_inexact.__init__(self, parent, approximation, prec, group=group, *args, **kwargs)
Exemplo n.º 3
0
 def _repr_(self):
     approximation = self._approximation
     length = max(approximation.length(), self.precision().last())
     if length >= 0:
         coeffs = [ self[i] for i in range(length) ]
         from printing import repr_polynomial
         return repr_polynomial(coeffs, self.variable_name())
     else:
         return RingElement_inexact._repr_(self)