8000 ENH: use rotated companion matrix to reduce error by mtmoncur · Pull Request #13202 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: use rotated companion matrix to reduce error #13202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion numpy/polynomial/chebyshev.py
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,8 @@ def chebroots(c):
if len(c) == 2:
return np.array([-c[0]/c[1]])

m = chebcompanion(c)
# rotated companion matrix reduces error
m = chebcompanion(c)[::-1,::-1]
r = la.eigvals(m)
r.sort()
return r
Expand Down
3 changes: 2 additions & 1 deletion numpy/polynomial/hermite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,8 @@ def hermroots(c):
if len(c) == 2:
return np.array([-.5*c[0]/c[1]])

m = hermcompanion(c)
# rotated companion matrix reduces error
m = hermcompanion(c)[::-1,::-1]
r = la.eigvals(m)
r.sort()
return r
Expand Down
3 changes: 2 additions & 1 deletion numpy/polynomial/hermite_e.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,8 @@ def hermeroots(c):
if len(c) == 2:
return np.array([-c[0]/c[1]])

m = hermecompanion(c)
# rotated companion matrix reduces error
m = hermecompanion(c)[::-1,::-1]
r = la.eigvals(m)
r.sort()
return r
Expand Down
3 changes: 2 additions & 1 deletion numpy/polynomial/laguerre.py
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,8 @@ def lagroots(c):
if len(c) == 2:
return np.array([1 + c[0]/c[1]])

m = lagcompanion(c)
# rotated companion matrix reduces error
m = lagcompanion(c)[::-1,::-1]
r = la.eigvals(m)
r.sort()
return r
Expand Down
3 changes: 2 additions & 1 deletion numpy/polynomial/legendre.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,8 @@ def legroots(c):
if len(c) == 2:
return np.array([-c[0]/c[1]])

m = legcompanion(c)
# rotated companion matrix reduces error
m = legcompanion(c)[::-1,::-1]
r = la.eigvals(m)
r.sort()
return r
Expand Down
3 changes: 2 additions & 1 deletion numpy/polynomial/polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,8 @@ def polyroots(c):
if len(c) == 2:
return np.array([-c[0]/c[1]])

m = polycompanion(c)
# rotated companion matrix reduces error
m = polycompanion(c)[::-1,::-1]
r = la.eigvals(m)
r.sort()
return r
Expand Down
0