1 | initial version |
On my machine, running Sage 9.4, i see no problem in the relative ordering:
sage: expr.support()
[34, 42, 58, 66]
sage: expr.coefficients()
[-2, 2*w3, -2, -2*w3 - 2]
sage: expr.monomials()
[v3[34], v3[42], v3[58], v3[66]]
However, the documentation of those methods are clear that the list is returned in an arbitrary order
, so that we can not rely on that.
According to git blame
+ git trac find
, you should find more details on trac ticket 18066
The sage: monomial_coefficients
method suggested by @john-palmieri is the way to go as it returns a dict
which links the elements of the support with the corresponding coefficients:
sage: expr.monomial_coefficients()
{34: -2, 42: 2*w3, 58: -2, 66: -2*w3 - 2}
2 | No.2 Revision |
On my machine, running Sage 9.4, i see no problem in the relative ordering:
sage: expr.support()
[34, 42, 58, 66]
sage: expr.coefficients()
[-2, 2*w3, -2, -2*w3 - 2]
sage: expr.monomials()
[v3[34], v3[42], v3[58], v3[66]]
However, the documentation of those methods are clear that the list is returned in an arbitrary order
, so that we can not rely on that.
According to git blame
+ git trac find
, you should find more details on trac ticket 18066
The sage: monomial_coefficients
method suggested by @john-palmieri is the way to go as it returns a dict
which links the elements of the support with the corresponding coefficients:
sage: expr.monomial_coefficients()
{34: -2, 42: 2*w3, 58: -2, 66: -2*w3 - 2}
or simply:
sage: dict(expr)
{34: -2, 42: 2*w3, 58: -2, 66: -2*w3 - 2}