summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Caruso <xavier.caruso@univ-rennes1.fr>2017-12-19 20:35:02 +0100
committerXavier Caruso <xavier.caruso@univ-rennes1.fr>2017-12-19 20:35:02 +0100
commit62c5d561fb0738e209e9f7372405d047e066f0a0 (patch)
tree13009dbdc6b4d179a95f14ecc178bcb19ac39210
parentMerge branch 'u/roed/lattice_precision' of git://trac.sagemath.org/sage into ... (diff)
Some doctests in lattice_precision.py
-rw-r--r--src/sage/rings/padics/lattice_precision.py459
-rw-r--r--src/sage/rings/padics/padic_lattice_element.py2
2 files changed, 454 insertions, 7 deletions
diff --git a/src/sage/rings/padics/lattice_precision.py b/src/sage/rings/padics/lattice_precision.py
index 1808afe..5180800 100644
--- a/src/sage/rings/padics/lattice_precision.py
+++ b/src/sage/rings/padics/lattice_precision.py
@@ -218,6 +218,13 @@ def format_history(tme, status, timings):
return status
class PrecisionLattice(UniqueRepresentation, SageObject):
+ """
+ A class for handling precision lattices which are used to
+ track precision in the ZpLP model.
+
+ The precision lattice is stored as a triangular matrix whose
+ rows are generators of the lattice.
+ """
# Internal variables:
# . self._cap
# a cap for the (working) precision
@@ -230,6 +237,8 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
# (its columns are indexed by self._elements)
# . self._absolute_precisions
def __init__(self, p, label):
+ """
+ """
self._p = p
self._label = label
self._elements = [ ]
@@ -242,9 +251,34 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
self._history = None
def label(self):
+ """
+ Return the label of the parent to which this precision lattice
+ corresponds.
+
+ EXAMPLE::
+
+ sage: R = ZpLP(2, label="mylabel")
+ sage: R.precision().label()
+ 'mylabel'
+ """
return self._label
def _repr_(self):
+ """
+ Return a string representation of this precision lattice
+
+ EXAMPLES::
+
+ sage: R = ZpLP(2)
+ sage: R.precision()
+ Precision Lattice on 0 object
+
+ If a label has been specified, it is included in the representation
+
+ sage: R = ZpLP(2, label="mylabel")
+ sage: R.precision()
+ Precision Lattice on 0 object (label: mylabel)
+ """
n = len(self._elements)
if self._label is None:
if n > 1:
@@ -258,9 +292,52 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
return "Precision Lattice on %s object (label: %s)" % (len(self._elements), self._label)
def prime(self):
+ """
+ Return the underlying prime number attached to this precision lattice.
+
+ EXAMPLE::
+
+ sage: R = ZpLP(2, label="mylabel")
+ sage: R.precision().prime()
+ 2
+ """
return self._p
def reduce(self, index=0, partial=False):
+ """
+ Perform a row reduction of the matrix representating this precision
+ lattice
+
+ INPUT:
+
+ - ``index`` -- an integer, the starting row for which the reduction
+ is performed
+
+ - ``partial`` -- a boolean (default: False) specifying whether a
+ partial or a full Hermite reduction should be performed
+
+ NOTE:
+
+ The partial reduction has cost `O(m^2)` where `m` is the number of
+ rows that need to be reduced (that is the difference between the
+ total number of rows and ``index``).
+
+ The full Hermite reduction has cost `O(m^3)`.
+
+ NOTE:
+
+ The software ensures that the precision lattice is always
+ partially reduced.
+ Calling the function manually with the argument ``partial=True``
+ should then just do nothing.
+
+ TESTS::
+
+ sage: R = ZpLP(2)
+ sage: x = R.random_element()
+ sage: del x
+ sage: R.precision().del_elements() # indirect doctest
+ """
n = len(self._elements)
if index >= n-1:
return
@@ -304,6 +381,46 @@ class PrecisionLattice(UniqueRepresentation, SageObject):
self._history.append(('full reduce', index, walltime(tme)))
def new_element(self, x, dx, bigoh, dx_mode='linear_combinaison'):
+ """
+ Update the lattice when a new element is created.
+
+ This function is not meant to be called manually.
+ It is automatically called by the parent when a new
+ element is created.
+
+ INPUT:
+
+ - ``x`` -- the newly created element
+
+ - ``dx`` -- a dictionary representing the differential of ``x``
+
+ - ``dx_mode`` -- a string, either ``linear_combinaison`` (the default)
+ or `values`
+
+ If ``dx_mode`` is ``linear_combinaison``, the dictionary ``dx``
+ encodes the expression of the differential of ``x``.
+ For example, if ``x`` was defined as ``x = y*z`` then:
+
+ .. MATH::
+
+ dx = y dz + z dy
+
+ and the corresponding dictionary is ``{z: y, y: z}`` (except
+ that the keys are not the elements themselves but weak references
+ to them).
+
+ If ``dx_mode`` is ``values``, the dictionary ``dx`` directly
+ specifies the entries that have to stored in the precision lattice.
+ This mode is only used for multiple conversion between differen