diff options
author | cookedm <cookedm@localhost> | 2005-10-30 23:01:20 +0000 |
---|---|---|
committer | cookedm <cookedm@localhost> | 2005-10-30 23:01:20 +0000 |
commit | cf44e43dd744f2a55ed90b253747499fef141dbc (patch) | |
tree | 7d0a92b8203b399635ccb1d14fee9887129561a7 /scipy/base/polynomial.py | |
parent | d3cb15876dfa9c2ef98f7814b32135bcd5cfde78 (diff) | |
download | numpy-cf44e43dd744f2a55ed90b253747499fef141dbc.tar.gz |
Don't use deconvolve for polydiv, as that requires scipy.signal to be installed.
Do it using synthetic division. Could be more efficient.
Diffstat (limited to 'scipy/base/polynomial.py')
-rw-r--r-- | scipy/base/polynomial.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/scipy/base/polynomial.py b/scipy/base/polynomial.py index ffdaa5849..46522c8c5 100644 --- a/scipy/base/polynomial.py +++ b/scipy/base/polynomial.py @@ -307,9 +307,17 @@ def polydiv(a1, a2): """Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s) """ truepoly = (isinstance(a1, poly1d) or isinstance(a2, poly1d)) - q, r = deconvolve(a1, a2) + monDivisor = NX.asarray(a2) / a2[0] + dividend = NX.asarray(a1) / a2[0] + q = [] + r = dividend + while len(r) >= len(monDivisor): + q.append(r[0]) + r = polysub(r, polymul(q, monDivisor))[1:] + q = NX.asarray(q) while NX.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1): r = r[1:] + r *= a2[0] if truepoly: q, r = map(poly1d, (q, r)) return q, r |