You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
roots(polynomial) drops zero roots if only one non-zero coeff in polynomial
Example (roots of x^{2} == 0)
numpy.roots((1,0,0))
array([], dtype=float64)
Also, roots fails if all coeffs are 0
numpy.roots((0,0))
Traceback (most recent call last):
File "", line 1, in ?
File "/afs/msc.cornell.edu/home/jsethna/ryang/installed/lib/python2.4/site-packages/numpy/lib/polynomial.py", line 96, in roots
trailing_zeros = len(p) - non_zero[-1] - 1
IndexError: index out of bounds
The attached patch fixes both issues. (For the all-zero polynomial, an empty array is returned. This is what matlab does.)
The text was updated successfully, but these errors were encountered:
Replying to [comment:1 oliphant]:
I don't agree that changeset 3265 closes ticket #921.
The modifications only solve the case when all coefficient are zero like
roots(poly1d([0,0,0])
but not when there is only one coefficient that is non-zero :
Sorry, as I got numpy from bleeding-edge apt-get repository (cf http://deb-scipy.alioth.debian.org/), I was thinking that I have a version with the bug fixed.
But with the previous example, I have the following result:
Original ticket http://projects.scipy.org/numpy/ticket/323 on 2006-10-05 by trac user RyanGutenkunst, assigned to unknown.
roots(polynomial) drops zero roots if only one non-zero coeff in polynomial
Example (roots of x^{2} == 0)
Also, roots fails if all coeffs are 0
The attached patch fixes both issues. (For the all-zero polynomial, an empty array is returned. This is what matlab does.)
The text was updated successfully, but these errors were encountered: