summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Caruso <xavier.caruso@univ-rennes1.fr>2018-01-06 11:28:33 +0100
committerXavier Caruso <xavier.caruso@univ-rennes1.fr>2018-01-06 11:28:33 +0100
commite9bb90bb49c864e679f9252ab940d95d4cbebaa4 (patch)
tree21d99584f7b3892bfbebc6c408ce2c859527f587
parentImplement relative cap (diff)
ZpLP -> ZpLC
-rw-r--r--src/sage/rings/padics/all.py4
-rw-r--r--src/sage/rings/padics/factory.py117
-rw-r--r--src/sage/rings/padics/lattice_precision.py44
-rw-r--r--src/sage/rings/padics/padic_base_leaves.py82
-rw-r--r--src/sage/rings/padics/padic_lattice_element.py66
5 files changed, 172 insertions, 141 deletions
diff --git a/src/sage/rings/padics/all.py b/src/sage/rings/padics/all.py
index 0ca7080..cf9be74 100644
--- a/src/sage/rings/padics/all.py
+++ b/src/sage/rings/padics/all.py
@@ -1,7 +1,7 @@
from __future__ import absolute_import
from .generic_nodes import is_pAdicField, is_pAdicRing
-from .factory import Zp, Zq, Zp as pAdicRing, ZpCR, ZpCA, ZpFM, ZpFP, ZpLP, ZqCR, ZqCA, ZqFM, ZqFP #, ZpL, ZqL
-from .factory import Qp, Qq, Qp as pAdicField, QpCR, QpFP, QpLP, QqCR, QqFP #, QpL, QqL
+from .factory import Zp, Zq, Zp as pAdicRing, ZpCR, ZpCA, ZpFM, ZpFP, ZpLC, ZqCR, ZqCA, ZqFM, ZqFP #, ZpL, ZqL
+from .factory import Qp, Qq, Qp as pAdicField, QpCR, QpFP, QpLC, QqCR, QqFP #, QpL, QqL
from .factory import pAdicExtension
from .padic_generic import local_print_mode
from .pow_computer import PowComputer
diff --git a/src/sage/rings/padics/factory.py b/src/sage/rings/padics/factory.py
index 7f2a227..792bc48 100644
--- a/src/sage/rings/padics/factory.py
+++ b/src/sage/rings/padics/factory.py
@@ -78,7 +78,7 @@ def _default_show_prec(type, print_mode):
INPUT:
- - ``type`` -- a string: ``'capped-rel'``, ``'capped-abs'``, ``'fixed-mod'``, ``'floating-point'`` or ``'lattice'``
+ - ``type`` -- a string: ``'capped-rel'``, ``'capped-abs'``, ``'fixed-mod'``, ``'floating-point'`` or ``'lattice-cap'``
- ``print_mode`` -- a string: ``'series'``, ``'terse'``, ``'val-unit'``, ``'digits'``, ``'bars'``
EXAMPLES::
@@ -127,7 +127,7 @@ def get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_se
p = Integer(p)
if not p.is_prime():
raise ValueError("p must be prime")
- if type == 'lattice':
+ if type == 'lattice-cap':
relative_cap = absolute_cap = None
if prec is not None:
# We first try to unpack
@@ -170,7 +170,7 @@ def get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_se
if prec is not None:
prec = Integer(prec)
if prec is None:
- if type == 'lattice':
+ if type == 'lattice-cap':
prec = (DEFAULT_PREC, 2*DEFAULT_PREC)
else:
prec = DEFAULT_PREC
@@ -612,7 +612,7 @@ class Qp_class(UniqueFactory):
print_alphabet = print_max_terms
print_max_terms = check
check = True
- return get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec, check, ['capped-rel', 'floating-point', 'lattice'], label, relprec, absprec)
+ return get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec, check, ['capped-rel', 'floating-point', 'lattice-cap'], label, relprec, absprec)
def create_object(self, version, key):
"""
@@ -665,7 +665,7 @@ class Qp_class(UniqueFactory):
else:
return pAdicFieldFloatingPoint(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet,
'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name)
- elif type == 'lattice':
+ elif type == 'lattice-cap':
if print_mode == 'terse':
return pAdicFieldLattice(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet,
'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name, label)
@@ -1254,20 +1254,20 @@ def QpFP(p, prec = None, *args, **kwds):
# EXAMPLES::
-def QpLP(p, prec = None, *args, **kwds):
+def QpLC(p, prec = None, *args, **kwds):
"""
A shortcut function to create `p`-adic fields with lattice precision.
- See :func:`ZpLP` for more information about this model of precision.
+ See :func:`ZpLC` for more information about this model of precision.
EXAMPLES::
- sage: R = QpLP(2)
+ sage: R = QpLC(2)
sage: R
2-adic Field with lattice precision
"""
- return Qp(p, prec, 'lattice', *args, **kwds)
+ return Qp(p, prec, 'lattice-cap', *args, **kwds)
def QqCR(q, prec = None, *args, **kwds):
"""
@@ -1299,20 +1299,20 @@ def QqFP(q, prec = None, *args, **kwds):
"""
return Qq(q, prec, 'floating-point', *args, **kwds)
-def QpLP(p, prec = None, *args, **kwds):
+def QpLC(p, prec = None, *args, **kwds):
"""
A shortcut function to create `p`-adic fields with lattice precision.
- See :func:`ZpLP` for more information about this model of precision.
+ See :func:`ZpLC` for more information about this model of precision.
EXAMPLES::
- sage: R = QpLP(2)
+ sage: R = QpLC(2)
sage: R
2-adic Field with lattice precision
"""
- return Qp(p, prec, 'lattice', *args, **kwds)
+ return Qp(p, prec, 'lattice-cap', *args, **kwds)
#######################################################################################################
@@ -1333,14 +1333,16 @@ class Zp_class(UniqueFactory):
- ``p`` -- integer: the `p` in `\mathbb{Z}_p`
- ``prec`` -- integer (default: ``20``) the precision cap of the
- ring. Except for the fixed modulus case, individual elements
+ ring. In the lattice capped case, ``prec`` can either be a
+ pair (``relative_cap``, ``absolute_cap``).
+ Except for the fixed modulus case, individual elements
keep track of their own precision. See TYPES and PRECISION
below.
- ``type`` -- string (default: ``'capped-rel'``) Valid types are
``'capped-rel'``, ``'capped-abs'``, ``'fixed-mod'``,
- ``'floating-point'`` and ``'lazy'`` (though lazy is not yet
- implemented). See TYPES and PRECISION below
+ ``'floating-point'`` and ``'lattice-cap'``.
+ See TYPES and PRECISION below
- ``print_mode`` -- string (default: ``None``). Valid modes are
``'series'``, ``'val-unit'``, ``'terse'``, ``'digits'``, and
@@ -1375,9 +1377,9 @@ class Zp_class(UniqueFactory):
TYPES AND PRECISION:
- There are two types of precision for a `p`-adic element. The first
- is relative precision, which gives the number of known `p`-adic
- digits::
+ There are three types of precision.
+ The first is relative precision; it gives the number of known
+ `p`-adic digits::
sage: R = Zp(5, 20, 'capped-rel', 'series'); a = R(675); a
2*5^2 + 5^4 + O(5^22)
@@ -1390,11 +1392,29 @@ class Zp_class(UniqueFactory):
sage: a.precision_absolute()
22
- There are five types of `p`-adic rings: capped relative rings
+ The third one is lattice precision.
+ It is not attached to a single `p`-adic number but is a unique
+ object modeling the precision on a set of `p`-adics, which is
+ typically the set of all elements within the same parent.
+
+ sage: R = ZpLC(17)
+ sage: x = R(1,10); y = R(1,5)
+ sage: R.precision()
+ Precision Lattice on 2 objects
+ sage: R.precision().precision_lattice()
+ [2015993900449 0]
+ [ 0 1419857]
+
+ We refer to the documentation of the function :func:`ZpLC` for
+ more information about this precision model.
+
+ ::
+
+ There are six types of `p`-adic rings: capped relative rings
(type= ``'capped-rel'``), capped absolute rings
(type= ``'capped-abs'``), fixed modulus rings (type= ``'fixed-mod'``),
- floating point rings (type=``'floating-point'``),
- and lazy rings (type= ``'lazy'``).
+ floating point rings (type=``'floating-point'``), lattice capped
+ rings (type=``'lattice-cap'``) and lazy rings (type= ``'lazy'``).
In the capped relative case, the relative precision of an element
is restricted to be at most a certain value, specified at the
@@ -1441,10 +1461,16 @@ class Zp_class(UniqueFactory):
in that elements do not trac their own precision. However, relative
precision is truncated with each operation rather than absolute precision.
+ On the contrary, the lattice type tracks precision using lattices
+ and automatic differentiation. It is rather slow but provides sharp
+ (often optimal) results regarding precision.
+ We refer to the documentation of the function :func:`ZpLC` for a
+ small demonstration of the capabilities of this precision model.
+
The lazy case will eventually support elements that can increase
their precision upon request. It is not currently implemented.
- PRINTING
+ PRINTING:
There are many different ways to print `p`-adic elements. The
way elements of a given ring print is controlled by options
@@ -1740,7 +1766,7 @@ class Zp_class(UniqueFactory):
print_max_terms = check
check = True
return get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_sep, print_alphabet,
- print_max_terms, show_prec, check, ['capped-rel', 'fixed-mod', 'capped-abs', 'floating-point', 'lattice'],
+ print_max_terms, show_prec, check, ['capped-rel', 'fixed-mod', 'capped-abs', 'floating-point', 'lattice-cap'],
label=label, relprec=relprec, absprec=absprec)
def create_object(self, version, key):
@@ -1772,7 +1798,7 @@ class Zp_class(UniqueFactory):
# keys changed in order to reduce irrelevant duplications: e.g. two Zps with print_mode 'series'
# that are identical except for different 'print_alphabet' now return the same object.
key = get_key_base(p, prec, type, print_mode, name, None, print_pos, print_sep, print_alphabet,
- print_max_terms, None, False, ['capped-rel', 'fixed-mod', 'capped-abs', 'lattice'])
+ print_max_terms, None, False, ['capped-rel', 'fixed-mod', 'capped-abs', 'lattice-cap'])
try:
obj = self._cache[version, key]()
if obj is not None:
@@ -1792,7 +1818,7 @@ class Zp_class(UniqueFactory):
elif type == 'floating-point':
return pAdicRingFloatingPoint(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet,
'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name)
- elif type == 'lattice':
+ elif type == 'lattice-cap':
return pAdicRingLattice(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet,
'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name, label)
else:
@@ -2463,13 +2489,16 @@ def ZqFP(q, prec = None, *args, **kwds):
"""
return Zq(q, prec, 'floating-point', *args, **kwds)
-def ZpLP(p, prec = None, *args, **kwds):
+def ZpLC(p, prec=None, *args, **kwds):
"""
- A shortcut function to create `p`-adic rings with lattice precision.
+ A shortcut function to create `p`-adic rings with lattice precision
+ with cap.
+
+ DEMONSTRATION:
Below is a small demo of the features by this model of precision::
- sage: R = ZpLP(3, print_mode='terse')
+ sage: R = ZpLC(3, print_mode='terse')
sage: x = R(1,10)
Of course, when we multiply by 3, we gain one digit of absolute
@@ -2498,7 +2527,7 @@ def ZpLP(p, prec = None, *args, **kwds):
This comes more funny when we are working with elements given
at different precisions::
- sage: R = ZpLP(2, print_mode='terse')
+ sage: R = ZpLC(2, print_mode='terse')
sage: x = R(1,10)
sage: y = R(1,5)
sage: z = x+y; z
@@ -2568,7 +2597,7 @@ def ZpLP(p, prec = None, *args, **kwds):
If instead, we use the lattice precision, everything goes well::
- sage: R = ZpLP(2, 30, print_mode='terse')
+ sage: R = ZpLC(2, 30, print_mode='terse')
sage: a,b,c,d = R(1,15), R(1,15), R(1,15), R(3,15)
sage: a,b,c,d = b,c,d,(b*d+c*c)/a; print(d)
4 + O(2^15)
@@ -2612,10 +2641,9 @@ def ZpLP(p, prec = None, *args, **kwds):
may share the same instance; this happens for instance for a
`p`-adic ring and its field of fractions.)
- This precision datum is accessible through the method
- :meth:`precision`::
+ This precision datum is accessible through the method :meth:`precision`::
- sage: R = ZpLP(5, print_mode='terse')
+ sage: R = ZpLC(5, print_mode='terse')
sage: prec = R.precision()
sage: prec
Precision Lattice on 0 object
@@ -2661,8 +2689,8 @@ def ZpLP(p, prec = None, *args, **kwds):
Observe that `5^10 = 9765625` and `5^5 = 3125`.
The above matrix then reflects the precision on `x` and `y`.
- Now, observe how the precision lattice changes while
- performing computations::
+ Now, observe how the precision lattice changes while performing
+ computations::
sage: x, y = 3*x+2*y, 2*(x-y)
sage: prec.del_elements()
@@ -2670,10 +2698,9 @@ def ZpLP(p, prec = None, *args, **kwds):
[ 3125 48825000]
[ 0 48828125]
- The matrix we get is no longer diagonal, meaning that
- some digits of precision are diffused among the two
- new elements `x` and `y`. They nevertheless show up
- when we compute for instance `x+y`::
+ The matrix we get is no longer diagonal, meaning that some digits
+ of precision are diffused among the two new elements `x` and `y`.
+ They nevertheless show up when we compute for instance `x+y`::
sage: x
1516 + O(5^5)
@@ -2682,9 +2709,9 @@ def ZpLP(p, prec = None, *args, **kwds):
sage: x+y
17565 + O(5^11)
- It is these diffused digits of precision (which are
- tracked but do not appear on the printing) that allow
- to be always sharp on precision.
+ These diffused digits of precision (which are tracked but
+ do not appear on the printing) allow to be always sharp on
+ precision.
PERFORMANCES:
@@ -2709,7 +2736,7 @@ def ZpLP(p, prec = None, *args, **kwds):
If enabled, it maintains an history of all actions and stores
the wall time of each of them::
- sage: R = ZpLP(3)
+ sage: R = ZpLC(3)
sage: prec = R.precision()
sage: prec.history_enable()
sage: M = random_matrix(R, 5)
@@ -2763,7 +2790,7 @@ def ZpLP(p, prec = None, *args, **kwds):
'partial reduce': 0.0917658805847168}
"""
- return Zp(p, prec, 'lattice', *args, **kwds)
+ return Zp(p, prec, 'lattice-cap', *args, **kwds)
#def ZpL(p, prec = DEFAULT_PREC, print_mode = None, halt = DEFAULT_HALT, names = None, print_pos = None,
# print_sep = None, print_alphabet = None, print_max_terms = None, check=True):
diff --git a/src/sage/rings/padics/lattice_precision.py b/src/sage/rings/padics/lattice_precision.py
index 80219fe..afba9a2 100644
--- a/src/sage/rings/padics/lattice_precision.py
+++ b/src/sage/rings/padics/lattice_precision.py
@@ -203,7 +203,7 @@ def list_of_padics(elements):
TESTS::
sage: from sage.rings.padics.lattice_precision import list_of_padics
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: M = random_matrix(R,2,2)
sage: list_of_padics(M)
[<weakref at 0x...; to 'pAdicLatticeElement' at 0x...>,
@@ -259,7 +259,7 @@ def format_history(tme, status, timings):
class PrecisionLattice(UniqueRepresentation, SageObject):
"""
A class for handling precision lattices which are used to
- track precision in the ZpLP model.
+ track precision in the ZpLC model.
The precision lattice is stored as a triangular matrix whose
rows are generators of the lattice.
@@ -295,7 +295,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLE::
- sage: R = ZpLP(2, label="mylabel")
+ sage: R = ZpLC(2, label="mylabel")
sage: R.precision().label()
'mylabel'
"""
@@ -307,13 +307,13 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: R.precision()
Precision Lattice on ... objects
If a label has been specified, it is included in the representation
- sage: R = ZpLP(2, label="mylabel")
+ sage: R = ZpLC(2, label="mylabel")
sage: R.precision()
Precision Lattice on 0 object (label: mylabel)
"""
@@ -335,7 +335,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLE::
- sage: R = ZpLP(2, label="mylabel")
+ sage: R = ZpLC(2, label="mylabel")
sage: R.precision().prime()
2
"""
@@ -370,7 +370,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
TESTS::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R.random_element()
sage: del x
sage: R.precision().del_elements() # indirect doctest
@@ -456,7 +456,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
TESTS::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R.random_element()
sage: y = R.random_element()
sage: z = x*y # indirect doctest
@@ -529,7 +529,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLES::
- sage: R = ZpLP(2, label='markdel')
+ sage: R = ZpLC(2, label='markdel')
sage: prec = R.precision()
sage: x = R(1,10)
sage: prec
@@ -564,7 +564,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLES::
- sage: R = ZpLP(2, label='delelts')
+ sage: R = ZpLC(2, label='delelts')
sage: prec = R.precision()
sage: x = R(1,10)
@@ -651,7 +651,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R(1,10); x
1 + O(2^10)
sage: y = R(1,5); y
@@ -746,7 +746,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R(1,10); x
1 + O(2^10)
sage: y = R(1,5); y
@@ -776,7 +776,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R(1,10); x
1 + O(2^10)
sage: x.is_precision_capped() # indirect doctest
@@ -806,7 +806,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLES::
- sage: R = ZpLP(2, label='preclattice')
+ sage: R = ZpLC(2, label='preclattice')
sage: prec = R.precision()
sage: x = R(1,10); y = R(1,5)
sage: u = x + y
@@ -896,7 +896,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: prec = R.precision()
sage: x = R(1,10); y = R(1,5)
sage: u = x + y
@@ -949,7 +949,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLES::
- sage: R = ZpLP(2, label='count')
+ sage: R = ZpLC(2, label='count')
sage: prec = R.precision()
sage: x = R(1,10); y = R(1,5)
sage: prec.number_of_tracked_elements()
@@ -995,7 +995,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLES::
- sage: R = ZpLP(2, label='tracked')
+ sage: R = ZpLC(2, label='tracked')
sage: prec = R.precision()
sage: x = R(1,10); y = R(1,5)
sage: prec.tracked_elements()
@@ -1050,7 +1050,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
TESTS::
- sage: R = ZpLP(2, label='history_en')
+ sage: R = ZpLC(2, label='history_en')
sage: prec = R.precision()
sage: print(prec.history()) # history is disabled by default
@@ -1080,7 +1080,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
TESTS::
- sage: R = ZpLP(2, label='history_dis')
+ sage: R = ZpLC(2, label='history_dis')
sage: prec = R.precision()
sage: print(prec.history()) # history is disabled by default
@@ -1114,7 +1114,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
TESTS::
- sage: R = ZpLP(2, label='history_clear')
+ sage: R = ZpLC(2, label='history_clear')
sage: prec = R.precision()
sage: prec.history_enable()
@@ -1176,7 +1176,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLES::
- sage: R = ZpLP(2, label='history_en')
+ sage: R = ZpLC(2, label='history_en')
sage: prec = R.precision()
We first enable history::
@@ -1331,7 +1331,7 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
EXAMPLES::
- sage: R = ZpLP(2, label='timings')
+ sage: R = ZpLC(2, label='timings')
sage: prec = R.precision()
sage: prec.history_enable()
sage: M = random_matrix(R,5,5)
diff --git a/src/sage/rings/padics/padic_base_leaves.py b/src/sage/rings/padics/padic_base_leaves.py
index 32269a6..70625d7 100644
--- a/src/sage/rings/padics/padic_base_leaves.py
+++ b/src/sage/rings/padics/padic_base_leaves.py
@@ -877,10 +877,10 @@ class pAdicLatticeGeneric(pAdicGeneric):
EXAMPLES::
- sage: ZpLP(5)._prec_type()
- 'lattice'
+ sage: ZpLC(5)._prec_type()
+ 'lattice-cap'
"""
- return 'lattice'
+ return 'lattice-cap'
def precision_cap(self):
"""
@@ -889,13 +889,13 @@ class pAdicLatticeGeneric(pAdicGeneric):
EXAMPLES::
- sage: R = ZpLP(3)
+ sage: R = ZpLC(3)
sage: R.precision_cap()
20
sage: R.precision_cap_relative()
20
- sage: R = ZpLP(3, absprec=20)
+ sage: R = ZpLC(3, absprec=20)
sage: R.precision_cap()
20
sage: R.precision_cap_relative()
@@ -918,11 +918,11 @@ class pAdicLatticeGeneric(pAdicGeneric):
EXAMPLES::
- sage: R = ZpLP(3)
+ sage: R = ZpLC(3)
sage: R.precision_cap_relative()
20
- sage: R = ZpLP(3, absprec=20)
+ sage: R = ZpLC(3, absprec=20)
sage: R.precision_cap_relative()
+Infinity
@@ -938,11 +938,11 @@ class pAdicLatticeGeneric(pAdicGeneric):
EXAMPLES::
- sage: R = ZpLP(3)
+ sage: R = ZpLC(3)
sage: R.precision_cap_absolute()
40
- sage: R = ZpLP(3, absprec=20)
+ sage: R = ZpLC(3, absprec=20)
sage: R.precision_cap_absolute()
20
@@ -958,7 +958,7 @@ class pAdicLatticeGeneric(pAdicGeneric):
EXAMPLES::
- sage: R = ZpLP(5,label='precision')
+ sage: R = ZpLC(5,label='precision')
sage: R.precision()
Precision Lattice on 0 object (label: precision)
@@ -990,10 +990,10 @@ class pAdicLatticeGeneric(pAdicGeneric):
EXAMPLES:
- sage: R = ZpLP(5)
+ sage: R = ZpLC(5)
sage: R.label() # no label by default
- sage: R = ZpLP(5, label='mylabel')
+ sage: R = ZpLC(5, label='mylabel')
sage: R.label()
'mylabel'
@@ -1001,14 +1001,14 @@ class pAdicLatticeGeneric(pAdicGeneric):
For example, assume that we first want to do some calculations
with matrices::
- sage: R = ZpLP(5, label='matrices')
+ sage: R = ZpLC(5, label='matrices')
sage: M = random_matrix(R, 4, 4)
sage: M.determinant() # somewhat random
Now, if we want to do another unrelated computations, we can
use a different label::
- sage: R = ZpLP(5, label='polynomials')
+ sage: R = ZpLC(5, label='polynomials')
sage: S.<x> = PolynomialRing(R)
sage: P = (x-1)*(x-2)*(x-3)*(x-4)*(x-5)
@@ -1038,7 +1038,7 @@ class pAdicLatticeGeneric(pAdicGeneric):
same parent, the software remembers that the created element
is actually equal to ``x`` (at infinite precision)::
- sage: R = ZpLP(2, absprec=50)
+ sage: R = ZpLC(2, absprec=50)
sage: x = R(1,10); x
1 + O(2^10)
sage: y = R(x) # indirect doctest
@@ -1071,7 +1071,7 @@ class pAdicLatticeGeneric(pAdicGeneric):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R(1,10); y = R(1,5)
sage: x,y = x+y, x-y
@@ -1090,7 +1090,7 @@ class pAdicLatticeGeneric(pAdicGeneric):
As a consequence, if we convert ``x`` and ``y`` separately, we
loose some precision::
- sage: R2 = ZpLP(2, label='copy')
+ sage: R2 = ZpLC(2, label='copy')
sage: x2 = R2(x); y2 = R2(y)
sage: x2
2 + O(2^5)
@@ -1187,11 +1187,11 @@ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric):
EXAMPLES::
- sage: R = ZpLP(next_prime(10^60)) # indirect doctest
+ sage: R = ZpLC(next_prime(10^60)) # indirect doctest
sage: type(R)
<class 'sage.rings.padics.padic_base_leaves.pAdicRingLattice_with_category'>
- sage: R = ZpLP(2,label='init') # indirect doctest
+ sage: R = ZpLC(2,label='init') # indirect doctest
sage: R
2-adic Ring with lattice precision (label: init)
@@ -1208,7 +1208,7 @@ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric):
EXAMPLES::
- sage: R = ZpLP(2); R # indirect doctest
+ sage: R = ZpLC(2); R # indirect doctest
2-adic Ring with lattice precision
sage: latex(R)
\mathbb Z_{2}
@@ -1245,7 +1245,7 @@ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: R.random_element() # random
2^3 + 2^4 + 2^5 + 2^6 + 2^7 + 2^10 + 2^11 + 2^14 + 2^15 + 2^16 + 2^17 + 2^18 + 2^19 + 2^21 + O(2^23)
@@ -1257,7 +1257,7 @@ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric):
p = self.prime()
x = ZZ.random_element(p**prec)
relcap = x.valuation(p) + self._prec_cap_relative
- if prec < relcap:
+ if relcap < prec:
prec = relcap
return self._element_class(self, x, prec=prec)
@@ -1271,7 +1271,7 @@ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric):
EXAMPLES::
- sage: R = ZpLP(2); R
+ sage: R = ZpLC(2); R
2-adic Ring with lattice precision
sage: R.integer_ring()
2-adic Ring with lattice precision
@@ -1289,7 +1289,7 @@ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric):
Labels are kept unchanged by this function::
- sage: R = ZpLP(2, label='test'); R
+ sage: R = ZpLC(2, label='test'); R
2-adic Ring with lattice precision (label: test)
sage: R.integer_ring()
2-adic Ring with lattice precision (label: test)
@@ -1302,7 +1302,8 @@ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric):
if print_mode is None:
return self
from sage.rings.padics.factory import Zp
- return Zp(self.prime(), self.precision_cap(), 'lattice', print_mode=self._modified_print_mode(print_mode),
+ return Zp(self.prime(), (self._prec_cap_relative, self._prec_cap_absolute),
+ 'lattice-cap', print_mode=self._modified_print_mode(print_mode),
names=self._uniformizer_print(), label=self._label)
def fraction_field(self, print_mode=None):
@@ -1315,7 +1316,7 @@ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric):
EXAMPLES::
- sage: R = ZpLP(2); R
+ sage: R = ZpLC(2); R
2-adic Ring with lattice precision
sage: K = R.fraction_field(); K
2-adic Field with lattice precision
@@ -1331,13 +1332,14 @@ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric):
Labels are kept unchanged by this function::
- sage: R = ZpLP(2, label='test'); R
+ sage: R = ZpLC(2, label='test'); R
2-adic Ring with lattice precision (label: test)
sage: R.fraction_field()
2-adic Field with lattice precision (label: test)
"""
from sage.rings.padics.factory import Qp
- return Qp(self.prime(), self.precision_cap(), 'lattice', print_mode=self._modified_print_mode(print_mode),
+ return Qp(self.prime(), (self._prec_cap_relative, self._prec_cap_absolute),
+ 'lattice-cap', print_mode=self._modified_print_mode(print_mode),
names=self._uniformizer_print(), label=self._label)
@@ -1359,11 +1361,11 @@ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric):
EXAMPLES::
- sage: R = QpLP(next_prime(10^60)) # indirect doctest
+ sage: R = QpLC(next_prime(10^60)) # indirect doctest
sage: type(R)
<class 'sage.rings.padics.padic_base_leaves.pAdicFieldLattice_with_category'>
- sage: R = QpLP(2,label='init') # indirect doctest
+ sage: R = QpLC(2,label='init') # indirect doctest
sage: R
2-adic Field with lattice precision (label: init)
@@ -1380,7 +1382,7 @@ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric):
EXAMPLES::
- sage: K = QpLP(2); K # indirect doctest
+ sage: K = QpLC(2); K # indirect doctest
2-adic Field with lattice precision
sage: latex(K)
\mathbb Q_{2}
@@ -1417,7 +1419,7 @@ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric):
EXAMPLES::
- sage: K = QpLP(2)
+ sage: K = QpLC(2)
sage: K.random_element() # random
2^3 + 2^4 + 2^5 + 2^6 + 2^7 + 2^10 + 2^11 + 2^14 + 2^15 + 2^16 + 2^17 + 2^18 + 2^19 + O(2^20)
@@ -1430,7 +1432,7 @@ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric):
p = self.prime()
x = ZZ.random_element(p**prec)
relcap = x.valuation(p) + self._prec_cap_relative
- if prec < relcap:
+ if relcap < prec:
prec = relcap
return self._element_class(self, x, prec=prec)
@@ -1444,7 +1446,7 @@ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric):
EXAMPLES::
- sage: K = QpLP(2); K
+ sage: K = QpLC(2); K
2-adic Field with lattice precision
sage: R = K.integer_ring(); R
2-adic Ring with lattice precision
@@ -1460,14 +1462,15 @@ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric):
Labels are kept unchanged by this function::
- sage: K = QpLP(2, label='test'); K
+ sage: K = QpLC(2, label='test'); K
2-adic Field with lattice precision (label: test)
sage: K.integer_ring()
2-adic Ring with lattice precision (label: test)
"""
from sage.rings.padics.factory import Zp
- return Zp(self.prime(), self.precision_cap(), 'lattice', print_mode=self._modified_print_mode(print_mode),
+ return Zp(self.prime(), (self._prec_cap_relative, self._prec_cap_absolute),
+ 'lattice-cap', print_mode=self._modified_print_mode(print_mode),
names=self._uniformizer_print(), label=self._label)
def fraction_field(self, print_mode=None):
@@ -1480,7 +1483,7 @@ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric):
EXAMPLES::
- sage: K = QpLP(2); K
+ sage: K = QpLC(2); K
2-adic Field with lattice precision
sage: K.fraction_field()
2-adic Field with lattice precision
@@ -1498,7 +1501,7 @@ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric):
Labels are kept unchanged by this function::
- sage: K = QpLP(2, label='test'); K
+ sage: K = QpLC(2, label='test'); K
2-adic Field with lattice precision (label: test)
sage: K.fraction_field()
2-adic Field with lattice precision (label: test)
@@ -1511,5 +1514,6 @@ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric):
if print_mode is None:
return self
from sage.rings.padics.factory import Qp
- return Qp(self.prime(), self.precision_cap(), 'lattice', print_mode=self._modified_print_mode(print_mode),
+ return Qp(self.prime(), (self._prec_cap_relative, self._prec_cap_absolute),
+ 'lattice-cap', print_mode=self._modified_print_mode(print_mode),
names=self._uniformizer_print(), label=self._label)
diff --git a/src/sage/rings/padics/padic_lattice_element.py b/src/sage/rings/padics/padic_lattice_element.py
index 42dbf5c..3c759b7 100644
--- a/src/sage/rings/padics/padic_lattice_element.py
+++ b/src/sage/rings/padics/padic_lattice_element.py
@@ -51,7 +51,7 @@ class pAdicLatticeElement(pAdicGenericElement):
TESTS::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R(1,10)
sage: hash(x) # somewhat random
"""
@@ -72,7 +72,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(2, print_mode='terse')
+ sage: R = ZpLC(2, print_mode='terse')
sage: x = R(1234,10); x
210 + O(2^10)
sage: x.approximation()
@@ -92,7 +92,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(2, print_mode='terse')
+ sage: R = ZpLC(2, print_mode='terse')
sage: x = R(1234,10); x
210 + O(2^10)
sage: x.approximation()
@@ -117,7 +117,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(2, label='precision')
+ sage: R = ZpLC(2, label='precision')
sage: x = R.random_element()
sage: y = R.random_element()
sage: x.precision_lattice()
@@ -138,7 +138,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(2, print_mode='terse')
+ sage: R = ZpLC(2, print_mode='terse')
sage: x = R(1234,10); x
210 + O(2^10)
sage: x.precision_absolute()
@@ -172,7 +172,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R(1,10); x
1 + O(2^10)
sage: x.is_precision_capped()
@@ -208,7 +208,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R(12,10); x
2^2 + 2^3 + O(2^10)
sage: x.valuation()
@@ -247,7 +247,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R(12,10); x
2^2 + 2^3 + O(2^10)
sage: x.precision_relative()
@@ -276,7 +276,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(19,5)
+ sage: R = ZpLC(19,5)
sage: a = R(-1); a
18 + 18*19 + 18*19^2 + 18*19^3 + 18*19^4 + O(19^5)
sage: b = R(-5/2); b
@@ -302,7 +302,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(19,5)
+ sage: R = ZpLC(19,5)
sage: a = R(-1); a
18 + 18*19 + 18*19^2 + 18*19^3 + 18*19^4 + O(19^5)
sage: b = R(-5/2); b
@@ -321,7 +321,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(19,5)
+ sage: R = ZpLC(19,5)
sage: a = R(-1); a
18 + 18*19 + 18*19^2 + 18*19^3 + 18*19^4 + O(19^5)
sage: b = R(-5/2); b
@@ -360,7 +360,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(19)
+ sage: R = ZpLC(19)
sage: a = R(-1,5); a
18 + 18*19 + 18*19^2 + 18*19^3 + 18*19^4 + O(19^5)
sage: b = R(-5/2,5); b
@@ -404,7 +404,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(19)
+ sage: R = ZpLC(19)
sage: x = R(-5/2,5); x
7 + 9*19 + 9*19^2 + 9*19^3 + 9*19^4 + O(19^5)
@@ -440,13 +440,13 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(7)
+ sage: R = ZpLC(7)
sage: a = R(8); a.add_bigoh(1)
1 + O(7)
sage: b = R(0); b.add_bigoh(3)
O(7^3)
- sage: R = QpLP(7,4)
+ sage: R = QpLC(7,4)
sage: a = R(8); a.add_bigoh(1)
1 + O(7)
sage: b = R(0); b.add_bigoh(3)
@@ -493,7 +493,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R(1,10); x
1 + O(2^10)
sage: x.lift_to_precision(15)
@@ -563,7 +563,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(5)
+ sage: R = ZpLC(5)
sage: R(0)._is_exact_zero()
False
sage: R(1)._is_exact_zero()
@@ -577,7 +577,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(5)
+ sage: R = ZpLC(5)
sage: R(0)._is_inexact_zero()
True
sage: R(1)._is_inexact_zero()
@@ -597,7 +597,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R(2/5,10); x
2 + 2^3 + 2^4 + 2^7 + 2^8 + O(2^10)
sage: x.is_zero()
@@ -628,11 +628,11 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES:
- sage: R = ZpLP(7)
+ sage: R = ZpLC(7)
sage: a = R(8); a.lift()
8
- sage: R = QpLP(7)
+ sage: R = QpLC(7)
sage: a = R(8); a.lift()
8
sage: b = R(8/7); b.lift()
@@ -647,11 +647,11 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(997, 7)
+ sage: R = ZpLC(997, 7)
sage: a = R(123456878908); a
964*997 + 572*997^2 + 124*997^3 + O(997^8)
- sage: S = ZpLP(5)
+ sage: S = ZpLC(5)
sage: b = S(17); b
2 + 3*5 + O(5^20)
@@ -667,7 +667,7 @@ class pAdicLatticeElement(pAdicGenericElement):
If the parent is a field no truncation is performed::
- sage: K = QpLP(5)
+ sage: K = QpLC(5)
sage: b = K(17); b
2 + 3*5 + O(5^20)
sage: b >> 1
@@ -691,7 +691,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(5)
+ sage: R = ZpLC(5)
sage: a = R(1000); a
3*5^3 + 5^4 + O(5^23)
sage: a >> 1
@@ -718,7 +718,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(17)
+ sage: R = ZpLC(17)
sage: a = R(18*17, 4)
sage: a.unit_part()
1 + 17 + O(17^3)
@@ -747,7 +747,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(17)
+ sage: R = ZpLC(17)
sage: a = R(18*17, 4)
sage: a.val_unit()
(1, 1 + 17 + O(17^3))
@@ -777,7 +777,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R(1,10); x
1 + O(2^10)
sage: y = x.copy()
@@ -793,7 +793,7 @@ class pAdicLatticeElement(pAdicGenericElement):
This function can also be used for coersion/conversion as follows::
- sage: K = QpLP(2)
+ sage: K = QpLC(2)
sage: y = x.copy(K)
sage: y
1 + O(2^10)
@@ -817,7 +817,7 @@ class pAdicLatticeElement(pAdicGenericElement):
If a parent is given, it must share the same precision object::
- sage: x.copy(ZpLP(5))
+ sage: x.copy(ZpLC(5))
Traceback (most recent call last):
...
TypeError: parent must share the same precision object
@@ -827,7 +827,7 @@ class pAdicLatticeElement(pAdicGenericElement):
...
TypeError: parent must share the same precision object
- sage: x.copy(ZpLP(2, label='other'))
+ sage: x.copy(ZpLC(2, label='other'))
Traceback (most recent call last):
...
TypeError: parent must share the same precision object
@@ -858,7 +858,7 @@ class pAdicLatticeElement(pAdicGenericElement):
TESTS::
- sage: R = ZpLP(2)
+ sage: R = ZpLC(2)
sage: x = R(1,10); x
1 + O(2^10)
sage: y = copy(x) # indirect doctest
@@ -877,7 +877,7 @@ class pAdicLatticeElement(pAdicGenericElement):
EXAMPLES::
- sage: R = ZpLP(5,10)
+ sage: R = ZpLC(5,10)
sage: x = R(123456789); x
4 + 2*5 + 5^2 + 4*5^3 + 5^5 + 5^6 + 5^8 + 3*5^9 + O(5^10)
sage: x.expansion()