diff options
Diffstat (limited to 'numpy/polynomial/hermite.py')
-rw-r--r-- | numpy/polynomial/hermite.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/numpy/polynomial/hermite.py b/numpy/polynomial/hermite.py index 627232d7c..32b50a866 100644 --- a/numpy/polynomial/hermite.py +++ b/numpy/polynomial/hermite.py @@ -287,10 +287,17 @@ def hermfromroots(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 = hermsub(hermmulx(prd), r*prd) - return prd + roots.sort() + n = len(roots) + p = [hermline(-r, 1) for r in roots] + while n > 1: + m = n//2 + tmp = [hermmul(p[i], p[i+m]) for i in range(m)] + if n%2: + tmp[0] = hermmul(tmp[0], p[-1]) + p = tmp + n = m + return p[0] def hermadd(c1, c2): |