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

three-argument pow() on integers returns IntegerMod #34143

Closed
yyyyx4 opened this issue Jul 10, 2022 · 9 comments
Closed

three-argument pow() on integers returns IntegerMod #34143

yyyyx4 opened this issue Jul 10, 2022 · 9 comments

Comments

@yyyyx4
Copy link
Member

yyyyx4 commented Jul 10, 2022

Example:

sage: pow(5,7,13).parent()
Ring of integers modulo 13

This contradicts the docstring ("Return (left ^ right) % modulus."), and it doesn't happen for other parents:

sage: R.<x> = GF(59)[]
sage: pow(x,123,x^5-x+1).parent()
Univariate Polynomial Ring in x over Finite Field of size 59

Component: basic arithmetic

Author: Lorenz Panny

Branch/Commit: 299f265

Reviewer: Dave Morris

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

@yyyyx4 yyyyx4 added this to the sage-9.7 milestone Jul 10, 2022
@yyyyx4
Copy link
Member Author

yyyyx4 commented Jul 11, 2022

Commit: 50a8539

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jul 11, 2022

Author: Lorenz Panny

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jul 11, 2022

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jul 11, 2022

New commits:

eae7a9amake pow(x,e,m) return an element with the same parent as x
50a8539update doctests that were relying on the incorrect behaviour

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 11, 2022

Changed commit from 50a8539 to 299f265

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 11, 2022

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

299f265add doctest for #34143

@DaveWitteMorris
Copy link
Member

Reviewer: Dave Morris

@DaveWitteMorris
Copy link
Member

comment:3

Thanks for fixing this. The documentation for lift just says "Lift an integer modulo n to the integers", but doesn't guarantee that the lift is the canonical one. However, looking at some of the code seems to show that the lift (i.e., the ivalue) is always in the correct range, so it seems to be ok.

I do think the docstring of lift should be revised to clarify this (unless I missed something), but that's not for this ticket.

@vbraun
Copy link
Member

vbraun commented Aug 1, 2022

Changed branch from public/fix_return_type_of_pow_with_modulus to 299f265

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