summaryrefslogtreecommitdiff
path: root/numpy/polynomial/legendre.py
diff options
context:
space:
mode:
authorTyler Moncur <mtmoncur@gmail.com>2019-04-08 17:00:10 -0600
committerTyler Moncur <mtmoncur@gmail.com>2019-04-08 17:21:36 -0600
commit732d52a4c3cd91b8a2e20b99823fcd233dc32112 (patch)
treee0e83571bb563ead4ebbe5f8967b898c78aef518 /numpy/polynomial/legendre.py
parent96cacd74e50d972df8f6c8704b0f4b3c3dfbc81c (diff)
downloadnumpy-732d52a4c3cd91b8a2e20b99823fcd233dc32112.tar.gz
ENH: rotate companion matrix for all polynomial bases
Diffstat (limited to 'numpy/polynomial/legendre.py')
-rw-r--r--numpy/polynomial/legendre.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/numpy/polynomial/legendre.py b/numpy/polynomial/legendre.py
index d56e2ae2c..9eec9740d 100644
--- a/numpy/polynomial/legendre.py
+++ b/numpy/polynomial/legendre.py
@@ -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