Opened 7 years ago
Closed 7 years ago
#17974 closed defect (fixed)
Fix conversion from PARI to multivariate polynomial rings
Reported by: | pbruin | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-6.6 |
Component: | algebra | Keywords: | multivariate polynomials pari |
Cc: | Merged in: | ||
Authors: | Peter Bruin | Reviewers: | Vincent Delecroix |
Report Upstream: | N/A | Work issues: | |
Branch: | 7a7e1cd (Commits, GitHub, GitLab) | Commit: | 7a7e1cd5fe3d77da4ed242ebab9f0cb03c52aaa9 |
Dependencies: | Stopgaps: |
Description
Conversion of multivariate polynomials from PARI does not always work:
sage: A.<a> = PolynomialRing(QQ) sage: B.<d,e> = PolynomialRing(A) sage: f = pari(a*d) sage: B(f) Traceback (most recent call last): ... TypeError: Unable to coerce PARI d to an Integer
A similar example:
sage: A.<a,b> = PolynomialRing(QQ) sage: B.<d,e> = PolynomialRing(A) sage: f = pari(a*d) sage: B(f) Traceback (most recent call last): ... TypeError: Could not find a mapping of the passed element to this ring.
Change History (9)
comment:1 Changed 7 years ago by
- Branch set to u/pbruin/17974-multivariate_polynomials_pari
- Commit set to 8be3fe6225d04415b144c8d36e87ec0e2595921e
- Status changed from new to needs_review
comment:2 follow-up: ↓ 3 Changed 7 years ago by
- Status changed from needs_review to needs_info
comment:3 in reply to: ↑ 2 ; follow-up: ↓ 4 Changed 7 years ago by
Hello Vincent,
Do you know how pari chooses the order of the variables
sage: A.<a> = PolynomialRing(QQ) sage: B.<d,e> = PolynomialRing(A) sage: f = pari(a*d) sage: f d*a sage: B(f) a*d
In PARI, the variables x
and y
are predefined (with x
of higher priority) and subsequent variables get a successively lower priority in the order in which they are encountered. Polynomials are printed with the variable of highest priority on the right. In this example PARI sees a
first, therefore it has higher priority than d
. Compare
sage: gp('a*d') d*a
On the other hand, what do you think of
sage: f.sage() Traceback (most recent call last): ... NameError: name 'd' is not defined
This is because user-defined names are not part of the default context in which the evaluation is done. You have to do
sage: f.sage({'a': a, 'd': d}) a*d
or
sage: f.sage(globals()) a*d
comment:4 in reply to: ↑ 3 ; follow-up: ↓ 5 Changed 7 years ago by
Replying to pbruin:
On the other hand, what do you think of
sage: f.sage() Traceback (most recent call last): ... NameError: name 'd' is not definedThis is because user-defined names are not part of the default context in which the evaluation is done. You have to do
sage: f.sage({'a': a, 'd': d}) a*dor
sage: f.sage(globals()) a*d
Ha nice! Could you add it to the documentation where you check pari conversion?
comment:5 in reply to: ↑ 4 Changed 7 years ago by
- Status changed from needs_info to needs_work
- Work issues set to expand documentation
Replying to vdelecroix:
Replying to pbruin:
You have to do
sage: f.sage({'a': a, 'd': d}) a*dor
sage: f.sage(globals()) a*dHa nice! Could you add it to the documentation where you check pari conversion?
OK, I can add it for completeness (there are somewhat similar examples in the documentation of f.sage()
).
comment:6 Changed 7 years ago by
- Commit changed from 8be3fe6225d04415b144c8d36e87ec0e2595921e to 7a7e1cd5fe3d77da4ed242ebab9f0cb03c52aaa9
Branch pushed to git repo; I updated commit sha1. New commits:
7a7e1cd | Trac 17974: add example for f.sage()
|
comment:7 Changed 7 years ago by
- Status changed from needs_work to needs_review
- Work issues expand documentation deleted
comment:8 Changed 7 years ago by
- Reviewers set to Vincent Delecroix
- Status changed from needs_review to positive_review
comment:9 Changed 7 years ago by
- Branch changed from u/pbruin/17974-multivariate_polynomials_pari to 7a7e1cd5fe3d77da4ed242ebab9f0cb03c52aaa9
- Resolution set to fixed
- Status changed from positive_review to closed
Hello,
Do you know how pari chooses the order of the variables
On the other hand, what do you think of
Vincent