summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Roe <roed.math@gmail.com>2017-08-21 04:49:20 +0000
committerDavid Roe <roed.math@gmail.com>2017-08-21 04:49:20 +0000
commit90a79f74235c9136d6266d221a53f95f91aa7795 (patch)
tree0d6b433322ae87fea36ac4ecb2a33171058329c8
parentUpdated SageMath version to 8.1.beta2 (diff)
parentMerge branch 'u/caruso/lattice_precision' of git://trac.sagemath.org/sage int... (diff)
Merge branch 'u/roed/lattice_precision' of git://trac.sagemath.org/sage into t/23505/lattice_precision
-rw-r--r--src/sage/rings/padics/all.py4
-rw-r--r--src/sage/rings/padics/factory.py368
-rw-r--r--src/sage/rings/padics/lattice_precision.py567
-rw-r--r--src/sage/rings/padics/padic_base_generic.py11
-rw-r--r--src/sage/rings/padics/padic_base_leaves.py206
-rw-r--r--src/sage/rings/padics/padic_lattice_element.py203
-rw-r--r--src/sage/rings/padics/padic_printing.pyx7
7 files changed, 1338 insertions, 28 deletions
diff --git a/src/sage/rings/padics/all.py b/src/sage/rings/padics/all.py
index 809b4aa..0ca7080 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, ZqCR, ZqCA, ZqFM, ZqFP #, ZpL, ZqL
-from .factory import Qp, Qq, Qp as pAdicField, QpCR, QpFP, QqCR, QqFP #, QpL, QqL
+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 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 6034161..e07d955 100644
--- a/src/sage/rings/padics/factory.py
+++ b/src/sage/rings/padics/factory.py
@@ -31,8 +31,10 @@ from .padic_base_leaves import (pAdicRingCappedRelative,
pAdicRingCappedAbsolute,
pAdicRingFixedMod,
pAdicRingFloatingPoint,
+ pAdicRingLattice,
pAdicFieldCappedRelative,
- pAdicFieldFloatingPoint)
+ pAdicFieldFloatingPoint,
+ pAdicFieldLattice)
from . import padic_printing
######################################################
@@ -95,7 +97,7 @@ def _default_show_prec(type, print_mode):
else:
return False
-def get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec, check, valid_non_lazy_types):
+def get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec, check, valid_non_lazy_types, label=None):
"""
This implements create_key for Zp and Qp: moving it here prevents code duplication.
@@ -105,9 +107,9 @@ def get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_se
sage: from sage.rings.padics.factory import get_key_base
sage: get_key_base(11, 5, 'capped-rel', None, None, None, None, ':', None, None, False, True, ['capped-rel'])
- (11, 5, 'capped-rel', 'series', '11', True, '|', (), -1, False)
+ (11, 5, 'capped-rel', 'series', '11', True, '|', (), -1, False, None)
sage: get_key_base(12, 5, 'capped-rel', 'digits', None, None, None, None, None, None, True, False, ['capped-rel'])
- (12, 5, 'capped-rel', 'digits', '12', True, '|', ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B'), -1, True)
+ (12, 5, 'capped-rel', 'digits', '12', True, '|', ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B'), -1, True, None)
"""
if prec is None:
prec = DEFAULT_PREC
@@ -186,7 +188,7 @@ def get_key_base(p, prec, type, print_mode, names, ram_name, print_pos, print_se
if show_prec is None:
show_prec = _default_show_prec(type, print_mode)
if type in valid_non_lazy_types:
- key = (p, prec, type, print_mode, name, print_pos, print_sep, tuple(print_alphabet), print_max_terms, show_prec)
+ key = (p, prec, type, print_mode, name, print_pos, print_sep, tuple(print_alphabet), print_max_terms, show_prec, label)
else:
print(type)
raise ValueError("type must be %s"%(", ".join(valid_non_lazy_types)))
@@ -537,7 +539,7 @@ class Qp_class(UniqueFactory):
"""
def create_key(self, p, prec = None, type = 'capped-rel', print_mode = None,
names = None, ram_name = None, print_pos = None,
- print_sep = None, print_alphabet = None, print_max_terms = None, show_prec=None, check = True):
+ print_sep = None, print_alphabet = None, print_max_terms = None, show_prec=None, check = True, label=None):
"""
Creates a key from input parameters for ``Qp``.
@@ -546,7 +548,7 @@ class Qp_class(UniqueFactory):
TESTS::
sage: Qp.create_key(5,40)
- (5, 40, 'capped-rel', 'series', '5', True, '|', (), -1, True)
+ (5, 40, 'capped-rel', 'series', '5', True, '|', (), -1, True, None)
"""
if isinstance(names, (int, Integer)):
# old pickle; names is what used to be halt.
@@ -556,7 +558,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'])
+ 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'], label)
def create_object(self, version, key):
"""
@@ -566,7 +568,7 @@ class Qp_class(UniqueFactory):
TESTS::
- sage: Qp.create_object((3,4,2),(5, 41, 'capped-rel', 'series', '5', True, '|', (), -1))
+ sage: Qp.create_object((3,4,2),(5, 41, 'capped-rel', 'series', '5', True, '|', (), -1, None))
5-adic Field with capped relative precision 41
"""
if version[0] < 3 or (version[0] == 3 and version[1] < 2) or (version[0] == 3 and version[1] == 2 and version[2] < 3):
@@ -576,7 +578,7 @@ class Qp_class(UniqueFactory):
p, prec, type, print_mode, name, print_pos, print_sep, print_alphabet, print_max_terms = key
show_prec = None
else:
- p, prec, type, print_mode, name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec = key
+ p, prec, type, print_mode, name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec, label = key
if isinstance(type, Integer):
# lazy
raise NotImplementedError("lazy p-adics need more work. Sorry.")
@@ -592,7 +594,7 @@ class Qp_class(UniqueFactory):
return obj
except KeyError:
pass
- p, prec, type, print_mode, name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec = key
+ p, prec, type, print_mode, name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec, label = key
if type == 'capped-rel':
if print_mode == 'terse':
@@ -608,6 +610,13 @@ 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':
+ 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)
+ else:
+ return pAdicFieldLattice(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:
raise ValueError("unexpected type")
@@ -1173,6 +1182,21 @@ def QpFP(p, prec = None, *args, **kwds):
"""
return Qp(p, prec, 'floating-point', *args, **kwds)
+def QpLP(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.
+
+ EXAMPLES::
+
+ sage: R = QpLP(2)
+ sage: R
+ 2-adic Field with lattice precision
+
+ """
+ return Qp(p, prec, 'lattice', *args, **kwds)
+
def QqCR(q, prec = None, *args, **kwds):
"""
A shortcut function to create capped relative unramified `p`-adic
@@ -1595,7 +1619,7 @@ class Zp_class(UniqueFactory):
"""
def create_key(self, p, prec = None, type = 'capped-rel', print_mode = None,
names = None, ram_name = None, print_pos = None, print_sep = None, print_alphabet = None,
- print_max_terms = None, show_prec = None, check = True):
+ print_max_terms = None, show_prec = None, check = True, label = None):
"""
Creates a key from input parameters for ``Zp``.
@@ -1604,9 +1628,9 @@ class Zp_class(UniqueFactory):
TESTS::
sage: Zp.create_key(5,40)
- (5, 40, 'capped-rel', 'series', '5', True, '|', (), -1, True)
+ (5, 40, 'capped-rel', 'series', '5', True, '|', (), -1, True, None)
sage: Zp.create_key(5,40,print_mode='digits')
- (5, 40, 'capped-rel', 'digits', '5', True, '|', ('0', '1', '2', '3', '4'), -1, False)
+ (5, 40, 'capped-rel', 'digits', '5', True, '|', ('0', '1', '2', '3', '4'), -1, False, None)
"""
if isinstance(names, (int, Integer)):
# old pickle; names is what used to be halt.
@@ -1617,7 +1641,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'])
+ print_max_terms, show_prec, check, ['capped-rel', 'fixed-mod', 'capped-abs', 'floating-point', 'lattice'], label=label)
def create_object(self, version, key):
"""
@@ -1627,7 +1651,7 @@ class Zp_class(UniqueFactory):
TESTS::
- sage: Zp.create_object((3,4,2),(5, 41, 'capped-rel', 'series', '5', True, '|', (), -1))
+ sage: Zp.create_object((3,4,2),(5, 41, 'capped-rel', 'series', '5', True, '|', (), -1, None))
5-adic Ring with capped relative precision 41
"""
if (version[0] < 3 or (len(version) > 1 and version[0] == 3 and version[1] < 2) or
@@ -1637,8 +1661,9 @@ class Zp_class(UniqueFactory):
elif version[0] < 8:
p, prec, type, print_mode, name, print_pos, print_sep, print_alphabet, print_max_terms = key
show_prec = None
+ label = None
else:
- p, prec, type, print_mode, name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec = key
+ p, prec, type, print_mode, name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec, label = key
if isinstance(type, Integer):
# lazy
raise NotImplementedError("lazy p-adics need more work. Sorry.")
@@ -1647,14 +1672,14 @@ 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'])
+ print_max_terms, None, False, ['capped-rel', 'fixed-mod', 'capped-abs', 'lattice'])
try:
obj = self._cache[version, key]()
if obj is not None:
return obj
except KeyError:
pass
- p, prec, type, print_mode, name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec = key
+ p, prec, type, print_mode, name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec, label = key
if type == 'capped-rel':
return pAdicRingCappedRelative(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)
@@ -1667,6 +1692,9 @@ class Zp_class(UniqueFactory):
elif type == 'floating-point':<