Opened 4 years ago
Closed 4 years ago
#18807 closed enhancement (fixed)
Provide .monomial() method for multivariate polynomial rings
Reported by:  klee  Owned by:  

Priority:  minor  Milestone:  sage6.9 
Component:  basic arithmetic  Keywords:  monomial 
Cc:  Merged in:  
Authors:  Kwankyu Lee  Reviewers:  Vincent Delecroix 
Report Upstream:  N/A  Work issues:  
Branch:  3c16200 (Commits)  Commit:  3c16200fe7f8c8551a5b64574e2c527b18904fb5 
Dependencies:  Stopgaps: 
Description
Some people, including me, find it not immediate to think of a syntax to construct a monomial in multivariate polynomial rings. Currently the suggested syntax is
P.({(1,2,3):1})
to construct the monomial x*y^2*z^3
. This ticket provides much intuitive .monomial()
method. It can be used like
P.monomial(1,2,3)
Change History (13)
comment:1 Changed 4 years ago by
 Branch set to u/klee/add_monomial_method
 Commit set to 144aff8e583268472bb5f62b9ec8f5e22ba84ef7
comment:2 Changed 4 years ago by
 Commit changed from 144aff8e583268472bb5f62b9ec8f5e22ba84ef7 to 6431b45ab50577e86df32d9917a835984b40904e
Branch pushed to git repo; I updated commit sha1. New commits:
6431b45  Addded one more example

comment:3 Changed 4 years ago by
 Status changed from new to needs_review
comment:4 Changed 4 years ago by
comment:5 Changed 4 years ago by
 Milestone changed from sage6.8 to sage6.9
comment:6 Changed 4 years ago by
 Reviewers set to Vincent Delecroix
 Status changed from needs_review to needs_work
Hello,
Please try to avoid trailing whitespaces (that are whitespaces before line break). There are three of them in your examples.
Instead of self.one()
it would be better to use self.base_ring().one()
as the value of the dictionary is intended to be the value of the coefficients (i.e. an element of the base ring).
Could you add something like the following in your examples
sage: m = R.monomial(1,2,3) sage: R.monomial(*m.degrees()) == m True
It would show the syntax for rebuilding a monomial from a tuple.
Vincent
comment:7 Changed 4 years ago by
 Commit changed from 6431b45ab50577e86df32d9917a835984b40904e to f14504947c9c7f272e06de275b22413c3b1e659a
Branch pushed to git repo; I updated commit sha1. New commits:
c92e924  Add .monomial() method to multivariate polynomial rings

6ef2b91  Addded one more example

4941b15  Merge branch 'develop' into trac18807

7f2ffe8  improved implementation and docstring

f145049  Merge branch 'u/klee/add_monomial_method' of git://trac.sagemath.org/sage into trac18807

comment:8 Changed 4 years ago by
 Status changed from needs_work to needs_review
comment:9 Changed 4 years ago by
Merged to the current beta. Adopted all reviewer's comments.
comment:10 Changed 4 years ago by
 Status changed from needs_review to needs_work
The patchbot reports an error (click on the yellow bulb. yellow means bad in general).
comment:11 Changed 4 years ago by
 Commit changed from f14504947c9c7f272e06de275b22413c3b1e659a to 3c16200fe7f8c8551a5b64574e2c527b18904fb5
Branch pushed to git repo; I updated commit sha1. New commits:
3c16200  Fixed a typo in the implementation.

comment:12 Changed 4 years ago by
 Status changed from needs_work to positive_review
comment:13 Changed 4 years ago by
 Branch changed from u/klee/add_monomial_method to 3c16200fe7f8c8551a5b64574e2c527b18904fb5
 Resolution set to fixed
 Status changed from positive_review to closed
New commits:
Add .monomial() method to multivariate polynomial rings