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

Allow conversion of strings to iterated polynomial rings #13327

Closed
novoselt opened this issue Aug 2, 2012 · 6 comments
Closed

Allow conversion of strings to iterated polynomial rings #13327

novoselt opened this issue Aug 2, 2012 · 6 comments

Comments

@novoselt
Copy link
Member

novoselt commented Aug 2, 2012

It is possible to convert strings and symbolic expressions to iterated polynomial rings in a single variable, but not many if the string contains names of coefficients:

sage: Rs = QQ["a"]["b"]
sage: Rs("a*b")
a*b
sage: Rm = QQ["a"]["b, c"]
sage: Rm("a*b")
Traceback (most recent call last):
...
TypeError: unable to convert string

The patch introduces gens_dict_recursive method and uses it instead of gens_dict in the conversion code:

sage: Rs = QQ["a"]["b"]
sage: Rs("a*b")
a*b
sage: Rm = QQ["a"]["b, c"]
sage: Rm("a*b")
a*b
sage: Rm.gens_dict_recursive()
{'a': a, 'c': c, 'b': b}

Component: commutative algebra

Author: Andrey Novoseltsev

Reviewer: Frédéric Chapoton

Merged: sage-5.4.beta1

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

@fchapoton
Copy link
Contributor

comment:2

Looks good to me. Maybe one could check

Rm("a*b").parent()

to be sure that it lands where it should ?

@novoselt
Copy link
Member Author

comment:3

Attachment: trac_13327_string_to_iterated_mpolyring.patch.gz

OK, added the check!

@fchapoton
Copy link
Contributor

comment:4

Ok, looks good to me. Positive review.

By the way, what do you think of that :

sage: QQ["a, a"]           
Multivariate Polynomial Ring in a, a over Rational Field

@novoselt
Copy link
Member Author

comment:5

I think this is horrible, as well as

sage: QQ["a"]["a"]
Univariate Polynomial Ring in a over Univariate Polynomial Ring in a over Rational Field

but some people think that it does not matter how something is printing and the name is meaningless.

From my point of view, all generator names should be distinct and different from generator names used in the base ring (recursively). Note that if this is enforced, then it is not possible to create polynomial rings with symbolic coefficients, since "any name is in SR". Since such polynomials are important (at least to me), the first step is to have symbolic rings with only explicitly specified names allows as variables. Then constructors can check for name collisions.

@novoselt
Copy link
Member Author

Reviewer: Frédéric Chapoton

@jdemeyer jdemeyer modified the milestones: sage-5.3, sage-5.4 Aug 28, 2012
@jdemeyer
Copy link

jdemeyer commented Sep 6, 2012

Merged: sage-5.4.beta1

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