summaryrefslogtreecommitdiff
path: root/numpy/lib/polynomial.py
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2008-12-13 16:18:04 +0000
committerPauli Virtanen <pav@iki.fi>2008-12-13 16:18:04 +0000
commitf947ff3bf90038bc0b37bc9b6a95138a0cf5e47a (patch)
tree21b7e635180e6e79688a2740535a1ebc01259e6f /numpy/lib/polynomial.py
parent57c9ad3baa68a11aa8cfd272e4ccbb9002526cf1 (diff)
downloadnumpy-f947ff3bf90038bc0b37bc9b6a95138a0cf5e47a.tar.gz
Get lstsq and eigvals from numpy.linalg, not from numpy.dual. Addresses Scipy ticket #800
Diffstat (limited to 'numpy/lib/polynomial.py')
-rw-r--r--numpy/lib/polynomial.py31
1 files changed, 4 insertions, 27 deletions
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py
index 4a70c9fa3..504a1271f 100644
--- a/numpy/lib/polynomial.py
+++ b/numpy/lib/polynomial.py
@@ -15,36 +15,13 @@ from numpy.lib.getlimits import finfo
from numpy.lib.twodim_base import diag, vander
from numpy.lib.shape_base import hstack, atleast_1d
from numpy.lib.function_base import trim_zeros, sort_complex
-eigvals = None
-lstsq = None
+from numpy.linalg import eigvals, lstsq
class RankWarning(UserWarning):
"""Issued by polyfit when Vandermonde matrix is rank deficient.
"""
pass
-def get_linalg_funcs():
- "Look for linear algebra functions in numpy"
- global eigvals, lstsq
- from numpy.dual import eigvals, lstsq
- return
-
-def _eigvals(arg):
- "Return the eigenvalues of the argument"
- try:
- return eigvals(arg)
- except TypeError:
- get_linalg_funcs()
- return eigvals(arg)
-
-def _lstsq(X, y, rcond):
- "Do least squares on the arguments"
- try:
- return lstsq(X, y, rcond)
- except TypeError:
- get_linalg_funcs()
- return lstsq(X, y, rcond)
-
def poly(seq_of_zeros):
"""
Return polynomial coefficients given a sequence of roots.
@@ -94,7 +71,7 @@ def poly(seq_of_zeros):
seq_of_zeros = atleast_1d(seq_of_zeros)
sh = seq_of_zeros.shape
if len(sh) == 2 and sh[0] == sh[1]:
- seq_of_zeros = _eigvals(seq_of_zeros)
+ seq_of_zeros = eigvals(seq_of_zeros)
elif len(sh) ==1:
pass
else:
@@ -177,7 +154,7 @@ def roots(p):
# build companion matrix and find its eigenvalues (the roots)
A = diag(NX.ones((N-2,), p.dtype), -1)
A[0, :] = -p[1:] / p[0]
- roots = _eigvals(A)
+ roots = eigvals(A)
else:
roots = NX.array([])
@@ -500,7 +477,7 @@ def polyfit(x, y, deg, rcond=None, full=False):
# solve least squares equation for powers of x
v = vander(x, order)
- c, resids, rank, s = _lstsq(v, y, rcond)
+ c, resids, rank, s = lstsq(v, y, rcond)
# warn on rank reduction, which indicates an ill conditioned matrix
if rank != order and not full: