Return Poly.coeffs in the oder that were provided
See original GitHub issueI think it would be useful to get the coefficients in the order that were provided to the constructor.
For example,
import galois
from galois import GF2
# 1 + x^4 + x^6
poly = galois.Poly([1, 0, 1, 0, 0, 0, 1], field=GF2, order="asc")
poly.coeffs
I would expect to respect the order="asc"
and return
GF([1, 0, 1, 0, 0, 0, 1], order=2)
instead of
GF([1, 0, 0, 0, 1, 0, 1], order=2)
A bit offtopic, but why is descending order the default and preferred one (for __str__
, Poly.string
, etc.)? Would it make sense to use same order as numpy.polynomial.polynomial.Polynomial.coef
, which is ascending?
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Coefficients of polynomial - MATLAB coeffs - MathWorks
This MATLAB function returns coefficients of the polynomial p with respect to all variables determined in p by symvar.
Read more >How to extract all coefficients in sympy - python - Stack Overflow
coeffs () returns a list containing all coefficients which has a value and ignores those whose coefficient is 0 whereas all_coeffs() returns all ......
Read more >How to interpret coefficients from a polynomial model fit?
So we say help(poly) . The description says: Returns or evaluates orthogonal polynomials of degree 1 to degree over the specified set of...
Read more >Polynomials Manipulation Module Reference
Construct polynomials from expressions. sympy.polys.polytools.degree(f, gen=0)[source]#. Return the degree of f in the given variable.
Read more >galois.Poly — galois documentation - Read the Docs
galois.Poly¶ ; degrees. An array of the polynomial degrees in degree-descending order. ; field. The Galois field to which the coefficients belong. ;...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey. To be candid, the polynomial coefficient ordering was something I debated quite a bit. I settled on something and decided to wait for feedback from users.
I do think it’s a good idea to allow preservation of the coefficient ordering. Perhaps that could be accomplished by adding a
Poly.order
property that holds theorder
kwarg value used at construction, either"asc"
or"desc"
. Then,Poly.coeffs
would return the coefficients inPoly.order
order.Are you also suggesting that if the new property
Poly.order = "asc"
thatstr()
andPoly.string
should return the string representation of the polynomial with ascending degrees? For instance,Poly(1 + x^4 + x^6, GF(2))
and1 + x^4 + x^6
whenPoly.order = "asc"
?As to the default, again I debated that. I’m open to changing the default to ascending. I’ve seen that in other libraries ascending is common.
To be clear up a typo (I think) from your example… Since you specified
order="asc"
, that polynomial is1 + x^2 + x^6
not1 + x^4 + x^6
. Do you agree?Yes, I think so. Thanks!