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

Fix __getitem__ and slicing for p-adics #13300

Open
saraedum opened this issue Jul 26, 2012 · 11 comments
Open

Fix __getitem__ and slicing for p-adics #13300

saraedum opened this issue Jul 26, 2012 · 11 comments

Comments

@saraedum
Copy link
Member

This is a meta-ticket to track progress on fixing __getitem__ and slicing of p-adic elements and their .expansion().

Depends on #13299
Depends on #14304
Depends on #26406
Depends on #26407
Depends on #26408

Component: padics

Author: Julian Rueth

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

@saraedum saraedum added this to the sage-5.11 milestone Jul 26, 2012
@saraedum
Copy link
Member Author

comment:1

The attached file (which has an extra 3 in the filename, sorry) fixes this.

To be consistent, indexing gives elements in the residue field. Mathematically, this seems to make sense, but is this really what one wants?

I'm running all doctests now to see if this breaks anything.

@saraedum
Copy link
Member Author

comment:2

The doctests worked, so I'm setting this to needs review.

@saraedum
Copy link
Member Author

Author: Julian Rueth

@roed314
Copy link
Contributor

roed314 commented Oct 24, 2012

comment:4

Attachment: trac_13330.patch.gz

I don't think that giving elements of the residue field is what we want, though I agree that the current behavior for unramified extensions is silly. I would like to be able to have

sage: K.<a> = Qq(7^2, 20)
sage: z = K.random_element()
sage: z == sum([z[i] * 7^i for i in range(20)])
True

without having to lift from the residue field.

Of course, sometimes you want to get at the coefficient of a in z, or the coefficient of a in z[0]. Here's an idea. For matrices, we have the following::

sage: M = matrix(ZZ,4,4,range(16))
sage: M[0]
(0, 1, 2, 3)
sage: M[0,0]
0
sage: M[0,:]
[0 1 2 3]
sage: M[:,0]
[ 0]
[ 4]
[ 8]
[12]
sage: M[1:3,1:4]
[ 5  6  7]
[ 9 10 11]

What if we used a similar tuple indexing scheme for p-adic elements? For example:

sage: K.<a> = Qq(5^4,5)
sage: z = K.random_element(); z
a^3*5^-2 + (3*a^3 + 3*a^2)*5^-1 + (3*a^3 + a^2 + 3*a) + 4*a^3*5 + (4*a + 2)*5^2 + O(5^3)
sage: z[0]
3*a^3 + a^2 + 3*a + O(5^3)
sage: z[2]
4*a + 2 + O(5)
sage: z[2].parent()
Unramified Extension of 5-adic Field with capped relative precision 5 in a defined by (1 + O(5^5))*x^4 + (O(5^5))*x^3 + (4 + O(5^5))*x^2 + (4 + O(5^5))*x + (2 + O(5^5))
sage: z[0,0]
O(5^3)
sage: z[0,0].parent()
5-adic Field with capped relative precision 5
sage: z[2,0]
2 + O(5)
sage: z[2,1]
4 + O(5)
sage: z[:-1]
a^3*5^-2 + O(5^-1)
sage: z[:1]
a^3*5^-2 + (3*a^3 + 3*a^2)*5^-1 + (3*a^3 + a^2 + 3*a) + O(5)
sage: z[:] == z[:,:] == z
True
sage: all([z[i,:] == z[i] for i in range(-3,2)])
True
sage: z[:,0]
2*5^2 + O(5^3)
sage: z[:,0].parent()
5-adic Field with capped relative precision 5
sage: z[:,1]
3 + 4*5^2 + O(5^3)
sage: z[:,2]
3*5^-1 + 1 + O(5^3)
sage: z[:,3]
5^-2 + 3*5^-1 + 3 + 4*5 + O(5^3)
sage: sum([a^j * z[:,j] for j in range(4)]) == z
True
sage: z[-1:2,1:3]
3*a^2*5^-1 + (a^2 + 3*a) + O(5^2)

The parent of z[i], z[i,T] and z[S,T] (for integer i and slices S,T) would be the unramified extension; the parent of z[i,j] and z[S,j] would be the ground field (or ring). Negative indices would never be considered as counting backward from a length, even for ring elements.

What do you think?

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@saraedum
Copy link
Member Author

comment:8

Let's think about this again once #14304 has been merged.

@saraedum
Copy link
Member Author

Changed dependencies from #13299 to #13299, #14304

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@saraedum
Copy link
Member Author

comment:10

I like your proposal. Let's discuss this at one of the IRC sessions.

@saraedum
Copy link
Member Author

saraedum commented Oct 4, 2018

Changed dependencies from #13299, #14304 to #13299, #14304, #26406, 26407

@saraedum

This comment has been minimized.

@saraedum

This comment has been minimized.

@saraedum
Copy link
Member Author

saraedum commented Oct 4, 2018

Changed dependencies from #13299, #14304, #26406, 26407 to #13299, #14304, #26406, #26407, #26408

@saraedum saraedum changed the title slice and __getitem__ do not work over unramified extensions of padics Fix __getitem__ and slicing for p-adics Oct 4, 2018
@mkoeppe mkoeppe removed this from the sage-6.4 milestone Dec 29, 2022
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

4 participants