def __init__(self, p, prec, print_mode, names, label=None): """ Initialization. TESTS:: sage: R = ZpLC(17) # indirect doctest sage: R._prec_type() 'lattice-cap' sage: R._subtype 'cap' sage: R = ZpLF(17) # indirect doctest sage: R._prec_type() 'lattice-float' sage: R._subtype 'float' """ from sage.rings.padics.lattice_precision import pRational self._approx_zero = pRational(p, 0) self._approx_one = pRational(p, 1) self._approx_minusone = pRational(p, -1) if label is None: self._label = None else: self._label = str(label) # We do not use the standard attribute element_class # because we need to be careful with precision # Instead we implement _element_constructor_ (cf below) if self._subtype == 'cap': (self._prec_cap_relative, self._prec_cap_absolute) = prec self._zero_cap = None self._precision = PrecisionLattice(p, label) element_class = pAdicLatticeCapElement elif self._subtype == 'float': self._prec_cap_relative = prec self._prec_cap_absolute = infinity self._zero_cap = prec self._precision = PrecisionModule(p, label, prec) element_class = pAdicLatticeFloatElement else: raise ValueError("subtype must be either 'cap' or 'float'") self._element_class = self.__make_element_class__(element_class) pAdicGeneric.__init__(self, self, p, prec, print_mode, names, None)
def __init__(self, p, prec, print_mode, names, label=None): """ Initialization. TESTS:: sage: R = ZpLC(17) # indirect doctest sage: R._prec_type() 'lattice-cap' sage: R._subtype 'cap' sage: R = ZpLF(17) # indirect doctest sage: R._prec_type() 'lattice-float' sage: R._subtype 'float' """ from sage.rings.padics.lattice_precision import pRational self._approx_zero = pRational(p, 0) self._approx_one = pRational(p, 1) self._approx_minusone = pRational(p, -1) if label is None: self._label = None else: self._label = str(label) # We do not use the standard attribute element_class # because we need to be careful with precision # Instead we implement _element_constructor_ (cf below) if self._subtype == 'cap': (self._prec_cap_relative, self._prec_cap_absolute) = prec self._zero_cap = None self._precision = PrecisionLattice(p, label) element_class = pAdicLatticeCapElement elif self._subtype == 'float': self._prec_cap_relative = prec self._prec_cap_absolute = infinity self._zero_cap = prec self._precision = PrecisionModule(p, label, prec) element_class = pAdicLatticeFloatElement else: raise ValueError("subtype must be either 'cap' or 'float'") self._element_class = self.__make_element_class__(element_class) pAdicGeneric.__init__(self, self, p, prec, print_mode, names, None)