Opened 23 months ago
Closed 20 months ago
#30041 closed defect (fixed)
coefficients of a polynomial yielding an element in an extension of a p-adic field
Reported by: | gh-walnutmonster | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-9.2 |
Component: | padics | Keywords: | |
Cc: | pbruin | Merged in: | |
Authors: | Noa Viner | Reviewers: | Travis Scrimshaw |
Report Upstream: | N/A | Work issues: | |
Branch: | ab10423 (Commits, GitHub, GitLab) | Commit: | ab10423effb8e04fcaf1957fdecc073de0bf582e |
Dependencies: | Stopgaps: |
Description
In SageMath 9.0, I do the following:
sage: K = Qp(3) sage: R.<x> = K[] sage: L.<b> = K.extension(x^3+3) sage: a = O(b^60)
and then I try to get the padded coefficients of the polynomial yielding this "almost zero" element
sage: a == 0 True sage: a._polynomial_list(pad=True) --------------------------------------------------------------------------- UnboundLocalError Traceback (most recent call last) <ipython-input-10-849cb5543284> in <module>() ----> 1 a._polynomial_list(pad=True) /opt/sagemath-9.0/local/lib/python3.7/site-packages/sage/rings/padics/padic_ZZ_pX_CR_element.pyx in sage.rings.padics.padic_ZZ_pX_CR_element.pAdicZZpXCRElement._polynomial_list (build/cythonized/sage/rings/padics/padic_ZZ_pX_CR_element.cpp:21303)() 2540 return [R(c, prec) >> k for c in L] 2541 else: -> 2542 return [R(c, (prec - i - 1) // e + 1) >> k for i, c in enumerate(L)] 2543 2544 def polynomial(self, var='x'): UnboundLocalError: local variable 'k' referenced before assignment
I think the output of the above should be the same as below
sage: K.zero()._polynomial_list(pad=True) [0] sage:
Change History (8)
comment:1 Changed 23 months ago by
comment:2 Changed 21 months ago by
- Branch set to u/gh-n-vi/coefficients_of_a_polynomial_yielding_an_element_in_an_extension_of_a_p_adic_field
comment:3 Changed 21 months ago by
- Commit set to ab10423effb8e04fcaf1957fdecc073de0bf582e
comment:4 Changed 21 months ago by
I changed the behaviour of _polynomial_list at file padic_ZZ_pX_CR_element.pyx, so that now:
sage: K = Qp(3) sage: R.<x> = K[] sage: L.<b> = K.extension(x^3+3) sage: a = O(b^60) sage: a._polynomial_list(pad=True) [O(3^20), O(3^20), O(3^20)] # and indeed: sage: b^0*O(3^20) + b^1*O(3^20) + b^2*O(3^20) O(b^60)
A more detailed example that demonstrates the behaviour of _polynomial_list on zeros:
sage: R.<x> = ZZ[] sage: W.<w> = Qp(5).extension(x^3-5) sage: W(0)._polynomial_list() [] sage: W(0)._polynomial_list(pad=True) [0, 0, 0] sage: W(O(w^7))._polynomial_list() [] sage: W(O(w^7))._polynomial_list(pad=True) [O(5^3), O(5^2), O(5^2)]
This behaviour is consistent with some other implementations of _polynomial_list, at files: CR_template.pxi, padic_ZZ_pX_CA_element.pyx, CA_template.pxi. In those files I also added doctests for the zero and O(w7) cases, to demonstrate their behaviour.
comment:5 Changed 21 months ago by
- Status changed from new to needs_review
comment:6 Changed 21 months ago by
- Reviewers set to Travis Scrimshaw
- Status changed from needs_review to positive_review
LGTM.
comment:7 Changed 21 months ago by
Thanks!
comment:8 Changed 20 months ago by
- Branch changed from u/gh-n-vi/coefficients_of_a_polynomial_yielding_an_element_in_an_extension_of_a_p_adic_field to ab10423effb8e04fcaf1957fdecc073de0bf582e
- Resolution set to fixed
- Status changed from positive_review to closed
See also #29932.