Skip to content

Commit

Permalink
Trac #31845: Error when computing norm or trace of inexact zero in Z_q
Browse files Browse the repository at this point in the history
In !SageMath 9.3:
{{{
sage: R.<a> = Zq(4)
sage: b = a - a
sage: b.trace()
Traceback (most recent call last):
...
AttributeError:
'sage.rings.padics.qadic_flint_CR.qAdicCappedRelativeElement' object has
no attribute 'ground_ring'
}}}
The attached branch fixes this and also changes a few instances of
"norm" to "trace" in the docstring of `trace_unram()`.

URL: https://trac.sagemath.org/31845
Reported by: pbruin
Ticket author(s): Peter Bruin
Reviewer(s): Vincent Delecroix
  • Loading branch information
Release Manager committed Jun 20, 2021
2 parents 78c482b + 1e3fcfd commit 00820ea
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/sage/libs/linkages/padics/unram_shared.pxi
Expand Up @@ -129,6 +129,12 @@ def norm_unram(self, base = None):
4*7^2 + 7^3 + O(7^22)
sage: b*b.frobenius()
4*7^2 + 7^3 + O(7^22)
Check that :trac:`31845` is fixed::
sage: R.<a> = Zq(4)
sage: (a - a).norm()
O(2^20)
"""
if base is not None:
if base is self.parent():
Expand All @@ -138,7 +144,7 @@ def norm_unram(self, base = None):
if self._is_exact_zero():
return self.parent().ground_ring()(0)
elif self._is_inexact_zero():
return self.ground_ring(0, self.valuation())
return self.parent().ground_ring()(0, self.valuation())
if self.valuation() == 0:
return self.parent().ground_ring()(self.matrix_mod_pn().det())
else:
Expand All @@ -155,10 +161,10 @@ def trace_unram(self, base = None):
Return the absolute or relative trace of this element.
If ``base`` is given then ``base`` must be a subfield of the
parent `L` of ``self``, in which case the norm is the relative
norm from `L` to ``base``.
parent `L` of ``self``, in which case the trace is the relative
trace from `L` to ``base``.
In all other cases, the norm is the absolute norm down to
In all other cases, the trace is the absolute trace down to
`\QQ_p` or `\ZZ_p`.
EXAMPLES::
Expand Down Expand Up @@ -202,6 +208,12 @@ def trace_unram(self, base = None):
4*5 + 5^2 + 5^3 + 2*5^4
sage: (a+b).trace()
4*5 + 5^2 + 5^3 + 2*5^4
Check that :trac:`31845` is fixed::
sage: R.<a> = Zq(4)
sage: (a - a).trace()
O(2^20)
"""
if base is not None:
if base is self.parent():
Expand All @@ -211,7 +223,7 @@ def trace_unram(self, base = None):
if self._is_exact_zero():
return self.parent().ground_ring()(0)
elif self._is_inexact_zero():
return self.ground_ring(0, self.precision_absolute())
return self.parent().ground_ring()(0, self.precision_absolute())
if self.valuation() >= 0:
return self.parent().ground_ring()(self.matrix_mod_pn().trace())
else:
Expand Down

0 comments on commit 00820ea

Please sign in to comment.