Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coefficients of a polynomial yielding an element in an extension of a p-adic field #30041

Closed
walnutmonster mannequin opened this issue Jul 1, 2020 · 10 comments
Closed

Comments

@walnutmonster
Copy link
Mannequin

walnutmonster mannequin commented Jul 1, 2020

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:

CC: @pjbruin

Component: padics

Author: Noa Viner

Branch/Commit: ab10423

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/30041

@walnutmonster walnutmonster mannequin added this to the sage-9.2 milestone Jul 1, 2020
@walnutmonster walnutmonster mannequin added c: padics labels Jul 1, 2020
@pjbruin
Copy link
Contributor

pjbruin commented Jul 3, 2020

comment:1

See also #29932.

@n-vi
Copy link
Mannequin

n-vi mannequin commented Sep 8, 2020

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 8, 2020

Commit: ab10423

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 8, 2020

Branch pushed to git repo; I updated commit sha1. New commits:

6ed7259Changing behaviour for consistency.
ab10423Fixing last commit by using the right file (from an updated version of sage).

@n-vi
Copy link
Mannequin

n-vi mannequin commented Sep 8, 2020

comment:4

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.

@n-vi
Copy link
Mannequin

n-vi mannequin commented Sep 8, 2020

Author: Noa Viner

@n-vi n-vi mannequin added the s: needs review label Sep 8, 2020
@tscrim
Copy link
Collaborator

tscrim commented Sep 10, 2020

Reviewer: Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented Sep 10, 2020

comment:6

LGTM.

@n-vi
Copy link
Mannequin

n-vi mannequin commented Sep 10, 2020

comment:7

Thanks!

@vbraun
Copy link
Member

vbraun commented Sep 15, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants