Opened 7 years ago

Closed 7 years ago

#13327 closed defect (fixed)

Allow conversion of strings to iterated polynomial rings

Reported by: novoselt Owned by: malb
Priority: major Milestone: sage-5.4
Component: commutative algebra Keywords:
Cc: Merged in: sage-5.4.beta1
Authors: Andrey Novoseltsev Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

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}

Attachments (1)

trac_13327_string_to_iterated_mpolyring.patch (2.6 KB) - added by novoselt 7 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by novoselt

  • Status changed from new to needs_review

comment:2 Changed 7 years ago by chapoton

Looks good to me. Maybe one could check

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

to be sure that it lands where it should ?

Changed 7 years ago by novoselt

comment:3 Changed 7 years ago by novoselt

OK, added the check!

comment:4 Changed 7 years ago by chapoton

  • Status changed from needs_review to positive_review

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

comment:5 Changed 7 years ago by novoselt

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.

comment:6 Changed 7 years ago by novoselt

  • Reviewers set to Frédéric Chapoton

comment:7 Changed 7 years ago by jdemeyer

  • Milestone changed from sage-5.3 to sage-5.4

comment:8 Changed 7 years ago by jdemeyer

  • Merged in set to sage-5.4.beta1
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.