Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" p-Adic Generic
A generic superclass for all p-adic parents.
AUTHORS:
- David Roe - Genya Zaytman: documentation - David Harvey: doctests - Julian Rueth (2013-03-16): test methods for basic arithmetic
"""
#***************************************************************************** # Copyright (C) 2007-2013 David Roe <roed.math@gmail.com> # William Stein <wstein@gmail.com> # Julian Rueth <julian.rueth@fsfe.org> # # Distributed under the terms of the GNU General Public License (GPL) # as published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # http://www.gnu.org/licenses/ #***************************************************************************** from __future__ import print_function from __future__ import absolute_import
from sage.misc.prandom import sample from sage.misc.misc import some_tuples from copy import copy
from sage.structure.richcmp import richcmp from sage.categories.principal_ideal_domains import PrincipalIdealDomains from sage.categories.morphism import Morphism from sage.categories.fields import Fields from sage.rings.infinity import infinity from .local_generic import LocalGeneric from sage.rings.ring import PrincipalIdealDomain from sage.rings.integer import Integer from sage.rings.padics.padic_printing import pAdicPrinter from sage.rings.padics.precision_error import PrecisionError from sage.misc.cachefunc import cached_method from sage.structure.richcmp import richcmp_not_equal
class pAdicGeneric(PrincipalIdealDomain, LocalGeneric): def __init__(self, base, p, prec, print_mode, names, element_class, category=None): """ Initialization.
INPUT:
- base -- Base ring. - p -- prime - print_mode -- dictionary of print options - names -- how to print the uniformizer - element_class -- the class for elements of this ring
EXAMPLES::
sage: R = Zp(17) #indirect doctest """ else:
def some_elements(self): r""" Returns a list of elements in this ring.
This is typically used for running generic tests (see :class:`TestSuite`).
EXAMPLES::
sage: Zp(2,4).some_elements() [0, 1 + O(2^4), 2 + O(2^5), 1 + 2^2 + 2^3 + O(2^4), 2 + 2^2 + 2^3 + 2^4 + O(2^5)] """
def _modified_print_mode(self, print_mode): """ Returns a dictionary of print options, starting with self's print options but modified by the options in the dictionary print_mode.
INPUT:
- print_mode -- dictionary with keys in ['mode', 'pos', 'ram_name', 'unram_name', 'var_name', 'max_ram_terms', 'max_unram_terms', 'max_terse_terms', 'sep', 'alphabet']
EXAMPLES::
sage: R = Zp(5) sage: R._modified_print_mode({'mode': 'bars'})['ram_name'] '5' """ print_mode = {} print_mode = {'mode': print_mode}
def ngens(self): """ Returns the number of generators of self.
We conventionally define this as 1: for base rings, we take a uniformizer as the generator; for extension rings, we take a root of the minimal polynomial defining the extension.
EXAMPLES::
sage: Zp(5).ngens() 1 sage: Zq(25,names='a').ngens() 1 """
def gens(self): """ Returns a list of generators.
EXAMPLES::
sage: R = Zp(5); R.gens() [5 + O(5^21)] sage: Zq(25,names='a').gens() [a + O(5^20)] sage: S.<x> = ZZ[]; f = x^5 + 25*x -5; W.<w> = R.ext(f); W.gens() [w + O(w^101)] """
def __richcmp__(self, other, op): """ Return 0 if self == other, and 1 or -1 otherwise.
We consider two p-adic rings or fields to be equal if they are equal mathematically, and also have the same precision cap and printing parameters.
EXAMPLES::
sage: R = Qp(7) sage: S = Qp(7,print_mode='val-unit') sage: R == S False sage: S = Qp(7,type='capped-rel') sage: R == S True sage: R is S True """ if not isinstance(other, pAdicGeneric): return NotImplemented
lx = self.prime() rx = other.prime() if lx != rx: return richcmp_not_equal(lx, rx, op)
lx = self.precision_cap() rx = other.precision_cap() if lx != rx: return richcmp_not_equal(lx, rx, op)
return self._printer.richcmp_modes(other._printer, op)
#def ngens(self): # return 1
#def gen(self, n = 0): # if n != 0: # raise IndexError, "only one generator" # return self(self.prime())
def print_mode(self): r""" Returns the current print mode as a string.
INPUT:
self -- a p-adic field
OUTPUT:
string -- self's print mode
EXAMPLES::
sage: R = Qp(7,5, 'capped-rel') sage: R.print_mode() 'series' """
def characteristic(self): r""" Returns the characteristic of self, which is always 0.
INPUT:
self -- a p-adic parent
OUTPUT:
integer -- self's characteristic, i.e., 0
EXAMPLES::
sage: R = Zp(3, 10,'fixed-mod'); R.characteristic() 0 """
def prime(self): """ Returns the prime, ie the characteristic of the residue field.
INPUT:
self -- a p-adic parent
OUTPUT:
integer -- the characteristic of the residue field
EXAMPLES::
sage: R = Zp(3,5,'fixed-mod') sage: R.prime() 3 """
def uniformizer_pow(self, n): """ Returns p^n, as an element of self.
If n is infinity, returns 0.
EXAMPLES::
sage: R = Zp(3, 5, 'fixed-mod') sage: R.uniformizer_pow(3) 3^3 + O(3^5) sage: R.uniformizer_pow(infinity) O(3^5) """ if n is infinity: return self(0) return self(self.prime_pow.pow_Integer_Integer(n))
def _unram_print(self): """ For printing. Will be None if the unramified subextension of self is of degree 1 over Z_p or Q_p.
EXAMPLES::
sage: Zp(5)._unram_print() """
def residue_characteristic(self): """ Return the prime, i.e., the characteristic of the residue field.
OUTPUT:
integer -- the characteristic of the residue field
EXAMPLES::
sage: R = Zp(3,5,'fixed-mod') sage: R.residue_characteristic() 3 """
def residue_class_field(self): """ Returns the residue class field.
INPUT:
self -- a p-adic ring
OUTPUT:
the residue field
EXAMPLES::
sage: R = Zp(3,5,'fixed-mod') sage: k = R.residue_class_field() sage: k Finite Field of size 3 """
def residue_field(self): """ Returns the residue class field.
INPUT:
self -- a p-adic ring
OUTPUT:
the residue field
EXAMPLES::
sage: R = Zp(3,5,'fixed-mod') sage: k = R.residue_field() sage: k Finite Field of size 3 """
def residue_ring(self, n): """ Returns the quotient of the ring of integers by the nth power of the maximal ideal.
EXAMPLES::
sage: R = Zp(11) sage: R.residue_ring(3) Ring of integers modulo 1331 """
def residue_system(self): """ Returns a list of elements representing all the residue classes.
INPUT:
self -- a p-adic ring
OUTPUT:
list of elements -- a list of elements representing all the residue classes
EXAMPLES::
sage: R = Zp(3, 5,'fixed-mod') sage: R.residue_system() [O(3^5), 1 + O(3^5), 2 + O(3^5)] """
def _fraction_field_key(self, print_mode=None): """ Changes print_mode from a dictionary to a tuple and raises a deprecation warning if it is present.
EXAMPLES::
sage: Zp(5)._fraction_field_key() sage: Zp(5)._fraction_field_key({"pos":False}) doctest:warning ... DeprecationWarning: Use the change method if you want to change print options in fraction_field() See http://trac.sagemath.org/23227 for details. (('pos', False),) """
@cached_method(key=_fraction_field_key) def fraction_field(self, print_mode=None): r""" Returns the fraction field of this ring or field.
For `\ZZ_p`, this is the `p`-adic field with the same options, and for extensions, it is just the extension of the fraction field of the base determined by the same polynomial.
The fraction field of a capped absolute ring is capped relative, and that of a fixed modulus ring is floating point.
INPUT:
- ``print_mode`` -- a dictionary containing print options. Defaults to the same options as this ring.
OUTPUT:
- the fraction field of this ring.
EXAMPLES::
sage: R = Zp(5, print_mode='digits') sage: K = R.fraction_field(); repr(K(1/3))[3:] '31313131313131313132' sage: L = R.fraction_field({'max_ram_terms':4}); repr(L(1/3))[3:] doctest:warning ... DeprecationWarning: Use the change method if you want to change print options in fraction_field() See http://trac.sagemath.org/23227 for details. '3132' sage: U.<a> = Zq(17^4, 6, print_mode='val-unit', print_max_terse_terms=3) sage: U.fraction_field() Unramified Extension in a defined by x^4 + 7*x^2 + 10*x + 3 with capped relative precision 6 over 17-adic Field sage: U.fraction_field({"pos":False}) == U.fraction_field() False
TESTS::
sage: R = ZpLC(2); R doctest:...: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation. See http://trac.sagemath.org/23505 for details. 2-adic Ring with lattice-cap precision sage: K = R.fraction_field(); K 2-adic Field with lattice-cap precision
sage: K = QpLC(2); K2 = K.fraction_field({'mode':'terse'}) sage: K2 is K False sage: K = QpLC(2, label='test'); K 2-adic Field with lattice-cap precision (label: test) sage: K.fraction_field() 2-adic Field with lattice-cap precision (label: test) sage: K.fraction_field({'mode':'series'}) is K True """ else:
def integer_ring(self, print_mode=None): r""" Returns the ring of integers of this ring or field.
For `\QQ_p`, this is the `p`-adic ring with the same options, and for extensions, it is just the extension of the ring of integers of the base determined by the same polynomial.
INPUT:
- ``print_mode`` -- a dictionary containing print options. Defaults to the same options as this ring.
OUTPUT:
- the ring of elements of this field with nonnegative valuation.
EXAMPLES::
sage: K = Qp(5, print_mode='digits') sage: R = K.integer_ring(); repr(R(1/3))[3:] '31313131313131313132' sage: S = K.integer_ring({'max_ram_terms':4}); repr(S(1/3))[3:] doctest:warning ... DeprecationWarning: Use the change method if you want to change print options in integer_ring() See http://trac.sagemath.org/23227 for details. '3132' sage: U.<a> = Qq(17^4, 6, print_mode='val-unit', print_max_terse_terms=3) sage: U.integer_ring() Unramified Extension in a defined by x^4 + 7*x^2 + 10*x + 3 with capped relative precision 6 over 17-adic Ring sage: U.fraction_field({"print_mode":"terse"}) == U.fraction_field() doctest:warning ... DeprecationWarning: Use the change method if you want to change print options in fraction_field() See http://trac.sagemath.org/23227 for details. False
TESTS::
sage: K = QpLC(2); K 2-adic Field with lattice-cap precision sage: R = K.integer_ring(); R 2-adic Ring with lattice-cap precision
sage: R = ZpLC(2); R2 = R.integer_ring({'mode':'terse'}) sage: R2 is R False sage: R = ZpLC(2, label='test'); R 2-adic Ring with lattice-cap precision (label: test) sage: R.integer_ring() 2-adic Ring with lattice-cap precision (label: test) sage: R.integer_ring({'mode':'series'}) is R True """ #Currently does not support fields with non integral defining polynomials. This should change when the padic_general_extension framework gets worked out. else:
def teichmuller(self, x, prec = None): r""" Returns the teichmuller representative of x.
INPUT:
- self -- a p-adic ring - x -- something that can be cast into self
OUTPUT:
- element -- the teichmuller lift of x
EXAMPLES::
sage: R = Zp(5, 10, 'capped-rel', 'series') sage: R.teichmuller(2) 2 + 5 + 2*5^2 + 5^3 + 3*5^4 + 4*5^5 + 2*5^6 + 3*5^7 + 3*5^9 + O(5^10) sage: R = Qp(5, 10,'capped-rel','series') sage: R.teichmuller(2) 2 + 5 + 2*5^2 + 5^3 + 3*5^4 + 4*5^5 + 2*5^6 + 3*5^7 + 3*5^9 + O(5^10) sage: R = Zp(5, 10, 'capped-abs', 'series') sage: R.teichmuller(2) 2 + 5 + 2*5^2 + 5^3 + 3*5^4 + 4*5^5 + 2*5^6 + 3*5^7 + 3*5^9 + O(5^10) sage: R = Zp(5, 10, 'fixed-mod', 'series') sage: R.teichmuller(2) 2 + 5 + 2*5^2 + 5^3 + 3*5^4 + 4*5^5 + 2*5^6 + 3*5^7 + 3*5^9 + O(5^10) sage: R = Zp(5,5) sage: S.<x> = R[] sage: f = x^5 + 75*x^3 - 15*x^2 +125*x - 5 sage: W.<w> = R.ext(f) sage: y = W.teichmuller(3); y 3 + 3*w^5 + w^7 + 2*w^9 + 2*w^10 + 4*w^11 + w^12 + 2*w^13 + 3*w^15 + 2*w^16 + 3*w^17 + w^18 + 3*w^19 + 3*w^20 + 2*w^21 + 2*w^22 + 3*w^23 + 4*w^24 + O(w^25) sage: y^5 == y True sage: g = x^3 + 3*x + 3 sage: A.<a> = R.ext(g) sage: b = A.teichmuller(1 + 2*a - a^2); b (4*a^2 + 2*a + 1) + 2*a*5 + (3*a^2 + 1)*5^2 + (a + 4)*5^3 + (a^2 + a + 1)*5^4 + O(5^5) sage: b^125 == b True
We check that :trac:`23736` is resolved::
sage: R.teichmuller(GF(5)(2)) 2 + 5 + 2*5^2 + 5^3 + 3*5^4 + O(5^5)
AUTHORS:
- Initial version: David Roe - Quadratic time version: Kiran Kedlaya <kedlaya@math.mit.edu> (3/27/07) """ # Since teichmuller representatives are defined at infinite precision, # we can lift to precision prec, as long as the absolute precision of ans is positive.
def teichmuller_system(self): r""" Returns a set of teichmuller representatives for the invertible elements of `\ZZ / p\ZZ`.
INPUT:
- self -- a p-adic ring
OUTPUT:
- list of elements -- a list of teichmuller representatives for the invertible elements of `\ZZ / p\ZZ`
EXAMPLES::
sage: R = Zp(3, 5,'fixed-mod', 'terse') sage: R.teichmuller_system() [1 + O(3^5), 242 + O(3^5)]
Check that :trac:`20457` is fixed::
sage: F.<a> = Qq(5^2,6) sage: F.teichmuller_system()[3] (2*a + 2) + (4*a + 1)*5 + 4*5^2 + (2*a + 1)*5^3 + (4*a + 1)*5^4 + (2*a + 3)*5^5 + O(5^6)
NOTES:
Should this return 0 as well? """
# def different(self): # raise NotImplementedError
# def automorphisms(self): # r""" # Returns the group of automorphisms of `\ZZ_p`, i.e. the trivial group. # """ # raise NotImplementedError
# def galois_group(self): # r""" # Returns the Galois group of `\ZZ_p`, i.e. the trivial group. # """ # raise NotImplementedError
# def hasGNB(self): # r""" # Returns whether or not `\ZZ_p` has a Gauss Normal Basis. # """ # raise NotImplementedError
def extension(self, modulus, prec = None, names = None, print_mode = None, implementation='FLINT', **kwds): """ Create an extension of this p-adic ring.
EXAMPLES::
sage: k = Qp(5) sage: R.<x> = k[] sage: l.<w> = k.extension(x^2-5); l Eisenstein Extension in w defined by x^2 - 5 with capped relative precision 40 over 5-adic Field
sage: F = list(Qp(19)['x'](cyclotomic_polynomial(5)).factor())[0][0] sage: L = Qp(19).extension(F, names='a') sage: L Unramified Extension in a defined by x^2 + 8751674996211859573806383*x + 1 with capped relative precision 20 over 19-adic Field """ else: print_mode = dict(print_mode) if "print_" + option in kwds: print_mode["print_" + option] = kwds["print_" + option] else: print_mode["print_" + option] = self._printer.dict()[option] if option in kwds: print_mode[option] = kwds[option] else: print_mode[option] = self._printer.dict()[option]
def _test_add(self, **options): """ Test addition of elements of this ring.
INPUT:
- ``options`` -- any keyword arguments accepted by :meth:`_tester`.
EXAMPLES::
sage: Zp(3)._test_add()
.. SEEALSO::
:class:`TestSuite`
"""
def _test_sub(self, **options): """ Test subtraction on elements of this ring.
INPUT:
- ``options`` -- any keyword arguments accepted by :meth:`_tester`.
EXAMPLES::
sage: Zp(3)._test_sub()
.. SEEALSO::
:class:`TestSuite`
"""
def _test_invert(self, **options): """ Test multiplicative inversion of elements of this ring.
INPUT:
- ``options`` -- any keyword arguments accepted by :meth:`_tester`.
EXAMPLES::
sage: Zp(3)._test_invert()
.. SEEALSO::
:class:`TestSuite`
"""
else: else:
def _test_mul(self, **options): """ Test multiplication of elements of this ring.
INPUT:
- ``options`` -- any keyword arguments accepted by :meth:`_tester`.
EXAMPLES::
sage: Zp(3)._test_mul()
.. SEEALSO::
:class:`TestSuite`
"""
else:
def _test_div(self, **options): """ Test division of elements of this ring.
INPUT:
- ``options`` -- any keyword arguments accepted by :meth:`_tester`.
EXAMPLES::
sage: Zp(3)._test_div()
.. SEEALSO::
:class:`TestSuite`
"""
else: else: # The following might be false if there is an absolute cap # tester.assertEqual(z.precision_relative(), min(x.precision_relative(), y.precision_relative()))
def _test_neg(self, **options): """ Test the negation operator on elements of this ring.
INPUT:
- ``options`` -- any keyword arguments accepted by :meth:`_tester`.
EXAMPLES::
sage: Zp(3)._test_neg()
.. SEEALSO::
:class:`TestSuite` """
def _test_log(self, **options): """ Test the log operator on elements of this ring.
INPUT:
- ``options`` -- any keyword arguments accepted by :meth:`_tester`.
EXAMPLES::
sage: Zp(3)._test_log()
.. SEEALSO::
:class:`TestSuite` """
# In the fixed modulus setting, rounding errors may occur
else:
def _test_teichmuller(self, **options): """ Test Teichmuller lifts.
INPUT:
- ``options`` -- any keyword arguments accepted by :meth:`_tester`.
EXAMPLES::
sage: Zp(3)._test_teichmuller()
.. SEEALSO::
:class:`TestSuite` """
else: except (NotImplementedError, AttributeError): pass
def _test_convert_residue_field(self, **options): r""" Test that conversion of residue field elements back to this ring works.
INPUT:
- ``options`` -- any keyword arguments accepted by :meth:`_tester`.
EXAMPLES::
sage: Zp(3)._test_convert_residue_field()
.. SEEALSO::
:class:`TestSuite` """
continue
@cached_method def _log_unit_part_p(self): """ Compute the logarithm of the unit-part of `p`.
If `\pi` is the uniformizer in this ring, then we can uniquely write `p=\pi^e u` where `u` is a `\pi`-adic unit. This method computes the logarithm of `u`.
This is a helper method for :meth:`sage.rings.padics.padic_generic_element.pAdicGenericElement.log`.
TESTS::
sage: R = Qp(3,5) sage: R._log_unit_part_p() O(3^5)
sage: S.<x> = ZZ[] sage: W.<pi> = R.extension(x^3-3) sage: W._log_unit_part_p() O(pi^15)
sage: W.<pi> = R.extension(x^3-3*x-3) sage: W._log_unit_part_p() 2 + pi + 2*pi^2 + pi^4 + pi^5 + 2*pi^7 + 2*pi^8 + pi^9 + 2*pi^10 + pi^11 + pi^12 + 2*pi^14 + O(pi^15)
"""
def frobenius_endomorphism(self, n=1): """ INPUT:
- ``n`` -- an integer (default: 1)
OUTPUT:
The `n`-th power of the absolute arithmetic Frobenius endomorphism on this field.
EXAMPLES::
sage: K.<a> = Qq(3^5) sage: Frob = K.frobenius_endomorphism(); Frob Frobenius endomorphism on Unramified Extension ... lifting a |--> a^3 on the residue field sage: Frob(a) == a.frobenius() True
We can specify a power::
sage: K.frobenius_endomorphism(2) Frobenius endomorphism on Unramified Extension ... lifting a |--> a^(3^2) on the residue field
The result is simplified if possible::
sage: K.frobenius_endomorphism(6) Frobenius endomorphism on Unramified Extension ... lifting a |--> a^3 on the residue field sage: K.frobenius_endomorphism(5) Identity endomorphism of Unramified Extension ...
Comparisons work::
sage: K.frobenius_endomorphism(6) == Frob True """
def _test_elements_eq_transitive(self, **options): """ The operator ``==`` is not transitive for `p`-adic numbers. We disable the check of the category framework by overriding this method.
EXAMPLES:
sage: R = Zp(3) sage: R(3) == R(0,1) True sage: R(0,1) == R(6) True sage: R(3) == R(6) False sage: R._test_elements_eq_transitive()
"""
def valuation(self): r""" Return the `p`-adic valuation on this ring.
OUTPUT:
a valuation that is normalized such that the rational prime `p` has valuation 1.
EXAMPLES::
sage: K = Qp(3) sage: R.<a> = K[] sage: L.<a> = K.extension(a^3 - 3) sage: v = L.valuation(); v 3-adic valuation sage: v(3) 1 sage: L(3).valuation() 3
The normalization is chosen such that the valuation restricts to the valuation on the base ring::
sage: v(3) == K.valuation()(3) True sage: v.restriction(K) == K.valuation() True
.. SEEALSO::
:meth:`NumberField_generic.valuation() <sage.rings.number_field.number_field.NumberField_generic.valuation>`, :meth:`Order.valuation() <sage.rings.number_field.order.Order.valuation>`
"""
class ResidueReductionMap(Morphism): """ Reduction map from a p-adic ring or field to its residue field or ring.
These maps must be created using the :meth:`_create_` method in order to support categories correctly.
EXAMPLES::
sage: from sage.rings.padics.padic_generic import ResidueReductionMap sage: R.<a> = Zq(125); k = R.residue_field() sage: f = ResidueReductionMap._create_(R, k); f Reduction morphism: From: Unramified Extension in a defined by x^3 + 3*x + 3 with capped relative precision 20 over 5-adic Ring To: Finite Field in a0 of size 5^3 """ @staticmethod def _create_(R, k): """ Initialization. We have to implement this as a static method in order to call ``__make_element_class__``.
INPUT:
- ``R`` -- a `p`-adic ring or field. - ``k`` -- the residue field of ``R``, or a residue ring of ``R``.
EXAMPLES::
sage: f = Zmod(49).convert_map_from(Zp(7)) sage: TestSuite(f).run() sage: K.<a> = Qq(125); k = K.residue_field(); f = k.convert_map_from(K) sage: TestSuite(f).run() """ else: raise RuntimeError("N must be a power of q") else:
def is_surjective(self): """ The reduction map is surjective.
EXAMPLES::
sage: GF(7).convert_map_from(Qp(7)).is_surjective() True """
def is_injective(self): """ The reduction map is far from injective.
EXAMPLES::
sage: GF(5).convert_map_from(ZpCA(5)).is_injective() False """
def _call_(self, x): """ Evaluate this morphism.
EXAMPLES::
sage: R.<a> = Zq(125); k = R.residue_field() sage: f = k.convert_map_from(R) sage: f(15) 0 sage: f(1/(1+a)) a0^2 + 4*a0 + 4
sage: Zmod(121).convert_map_from(Qp(11))(3/11) Traceback (most recent call last): ... ValueError: element must have non-negative valuation in order to compute residue. """
def section(self): """ Returns the section from the residue ring or field back to the p-adic ring or field.
EXAMPLES::
sage: GF(3).convert_map_from(Zp(3)).section() Lifting morphism: From: Finite Field of size 3 To: 3-adic Ring with capped relative precision 20 """
def _repr_type(self): """ Type of morphism, for printing.
EXAMPLES::
sage: GF(3).convert_map_from(Zp(3))._repr_type() 'Reduction' """
def _richcmp_(self, other, op): r""" Compare this element to ``other`` with respect to ``op``.
EXAMPLES::
sage: from sage.rings.padics.padic_generic import ResidueReductionMap sage: f = ResidueReductionMap._create_(Zp(3), GF(3)) sage: g = ResidueReductionMap._create_(Zp(3), GF(3)) sage: f is g False sage: f == g True """ return NotImplemented
# A class for the Teichmuller lift would also be reasonable....
class ResidueLiftingMap(Morphism): """ Lifting map to a p-adic ring or field from its residue field or ring.
These maps must be created using the :meth:`_create_` method in order to support categories correctly.
EXAMPLES::
sage: from sage.rings.padics.padic_generic import ResidueLiftingMap sage: R.<a> = Zq(125); k = R.residue_field() sage: f = ResidueLiftingMap._create_(k, R); f Lifting morphism: From: Finite Field in a0 of size 5^3 To: Unramified Extension in a defined by x^3 + 3*x + 3 with capped relative precision 20 over 5-adic Ring """ @staticmethod def _create_(k, R): """ Initialization. We have to implement this as a static method in order to call ``__make_element_class__``.
INPUT:
- ``k`` -- the residue field of ``R``, or a residue ring of ``R``. - ``R`` -- a `p`-adic ring or field.
EXAMPLES::
sage: f = Zp(3).convert_map_from(Zmod(81)) sage: TestSuite(f).run() """ raise RuntimeError("N must be a power of q")
def _call_(self, x): """ Evaluate this morphism.
EXAMPLES::
sage: R.<a> = Zq(27); k = R.residue_field(); a0 = k.gen() sage: f = R.convert_map_from(k); f Lifting morphism: From: Finite Field in a0 of size 3^3 To: Unramified Extension in a defined by x^3 + 2*x + 1 with capped relative precision 20 over 3-adic Ring sage: f(a0 + 1) (a + 1) + O(3)
sage: Zp(3)(Zmod(81)(0)) O(3^4) """ else: raise NotImplementedError
def _call_with_args(self, x, args=(), kwds={}): """ Evaluate this morphism with extra arguments.
EXAMPLES::
sage: f = Zp(2).convert_map_from(Zmod(128)) sage: f(7, 5) # indirect doctest 1 + 2 + 2^2 + O(2^5) """ else: kwds['absprec'] = min(kwds.get('absprec', self._n), self._n) elif R.f() == 1: return R([x], *args, **kwds) elif R.e() == 1: return R(x.polynomial().list(), *args, **kwds) else: raise NotImplementedError
def _repr_type(self): """ Type of morphism, for printing.
EXAMPLES::
sage: Zp(3).convert_map_from(GF(3))._repr_type() 'Lifting' """
def _richcmp_(self, other, op): r""" Compare this element to ``other`` with respect to ``op``.
EXAMPLES::
sage: from sage.rings.padics.padic_generic import ResidueLiftingMap sage: f = ResidueLiftingMap._create_(GF(3), Zp(3)) sage: g = ResidueLiftingMap._create_(GF(3), Zp(3)) sage: f is g False sage: f == g True """ return NotImplemented
def local_print_mode(obj, print_options, pos = None, ram_name = None): r""" Context manager for safely temporarily changing the print_mode of a p-adic ring/field.
EXAMPLES::
sage: R = Zp(5) sage: R(45) 4*5 + 5^2 + O(5^21) sage: with local_print_mode(R, 'val-unit'): ....: print(R(45)) 5 * 9 + O(5^21)
.. NOTE::
For more documentation see ``localvars`` in parent_gens.pyx """ raise TypeError("print_options must be a dictionary or a string") print_options['pos'] = pos print_options['ram_name'] = ram_name |