#17922: coefficients() function more consistent between Expressions and
polynomial
rings
-------------------------------------------------+-------------------------
Reporter: JoalHeagney | Owner:
Type: enhancement | Status: new
Priority: minor | Milestone: sage-6.6
Component: algebra | Resolution:
Keywords: coeffs, rings, polynomials, | Merged in:
expression, symbolic | Reviewers:
Authors: | Work issues:
Report Upstream: N/A | Commit:
Branch: | Stopgaps:
Dependencies: |
-------------------------------------------------+-------------------------
Old description:
> {{{
> y = 3*x^3 + 2*x^2 - 4*x
> print(y)
> type(y)
> }}}
> Gives:
>
> {{{
> 3*x^3 + 2*x^2 - 4*x
> <type 'sage.symbolic.expression.Expression'>
> }}}
> And
>
> {{{
> M = matrix(SR,[[1,2],[0,-2]])
> ch = M.charpoly()
> print(ch)
> type(ch)
> }}}
> gives
>
> {{{
> x^2 + x - 2
> <class
> 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_dense_field'>
> }}}
> But:
>
> {{{
> y.coeffs()
> }}}
> returns
>
> {{{
> [[−4,1],[2,2],[3,3]]
> }}}
> and
>
> {{{
> ch.coeffs()
> }}}
> returns
>
> {{{
> [−2,1,1]
> }}}
>
> I'd prefer if these two functions returned the same format, preferably
> the Expression format, as having access to the index allows list
> comprehension tastiness.
New description:
The different behaviour between the two rings consists of
1. the `coefficients(sparse=True)` (which is default) method returns a
list of pairs in `SR`, and a list in `PolynomialRing`,
2. `Expression.dict()` does not exist.
Example:
{{{
y = 3*x^3 + 2*x^2 - 4*x
print(y)
type(y)
}}}
Gives:
{{{
3*x^3 + 2*x^2 - 4*x
<type 'sage.symbolic.expression.Expression'>
}}}
And
{{{
M = matrix(SR,[[1,2],[0,-2]])
ch = M.charpoly()
print(ch)
type(ch)
}}}
gives
{{{
x^2 + x - 2
<class
'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_dense_field'>
}}}
But:
{{{
y.coeffs()
}}}
returns
{{{
[[−4,1],[2,2],[3,3]]
}}}
and
{{{
ch.coeffs()
}}}
returns
{{{
[−2,1,1]
}}}
I'd prefer if these two functions returned the same format, preferably the
Expression format, as having access to the index allows list comprehension
tastiness.
--
Comment (by rws):
Clarified the ticket description.
--
Ticket URL: <http://trac.sagemath.org/ticket/17922#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.