summaryrefslogtreecommitdiff
path: root/numpy/polynomial/chebyshev.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/polynomial/chebyshev.py')
-rw-r--r--numpy/polynomial/chebyshev.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/numpy/polynomial/chebyshev.py b/numpy/polynomial/chebyshev.py
index 022dccfa7..ab4c96a54 100644
--- a/numpy/polynomial/chebyshev.py
+++ b/numpy/polynomial/chebyshev.py
@@ -540,10 +540,17 @@ def chebfromroots(roots) :
return np.ones(1)
else :
[roots] = pu.as_series([roots], trim=False)
- prd = np.array([1], dtype=roots.dtype)
- for r in roots:
- prd = chebsub(chebmulx(prd), r*prd)
- return prd
+ roots.sort()
+ n = len(roots)
+ p = [chebline(-r, 1) for r in roots]
+ while n > 1:
+ m = n//2
+ tmp = [chebmul(p[i], p[i+m]) for i in range(m)]
+ if n%2:
+ tmp[0] = chebmul(tmp[0], p[-1])
+ p = tmp
+ n = m
+ return p[0]
def chebadd(c1, c2):