summaryrefslogtreecommitdiff
path: root/numpy/linalg/linalg.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2015-09-26 11:36:14 -0600
committerCharles Harris <charlesr.harris@gmail.com>2015-09-26 11:36:14 -0600
commitdbd2324d8e28dcdac53f800cc3d11158bac3ff7b (patch)
treec583e5183d88ecf7637b63b1b919beb5a184e75a /numpy/linalg/linalg.py
parent1bf73fa0119fc4ed9ab771d01e1cee5e9fd36c76 (diff)
parentae56c58db4207bd11100a9d24c9edf7694e34d67 (diff)
downloadnumpy-dbd2324d8e28dcdac53f800cc3d11158bac3ff7b.tar.gz
Merge pull request #6362 from seberg/issue6351
BUG,ENH: allow linalg.cond to work on a stack of matrices
Diffstat (limited to 'numpy/linalg/linalg.py')
-rw-r--r--numpy/linalg/linalg.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py
index a2405c180..f5cb3cb77 100644
--- a/numpy/linalg/linalg.py
+++ b/numpy/linalg/linalg.py
@@ -1012,9 +1012,9 @@ def eig(a):
w : (..., M) array
The eigenvalues, each repeated according to its multiplicity.
The eigenvalues are not necessarily ordered. The resulting
- array will be of complex type, unless the imaginary part is
- zero in which case it will be cast to a real type. When `a`
- is real the resulting eigenvalues will be real (0 imaginary
+ array will be of complex type, unless the imaginary part is
+ zero in which case it will be cast to a real type. When `a`
+ is real the resulting eigenvalues will be real (0 imaginary
part) or occur in conjugate pairs
v : (..., M, M) array
@@ -1382,7 +1382,7 @@ def cond(x, p=None):
Parameters
----------
- x : (M, N) array_like
+ x : (..., M, N) array_like
The matrix whose condition number is sought.
p : {None, 1, -1, 2, -2, inf, -inf, 'fro'}, optional
Order of the norm:
@@ -1451,12 +1451,12 @@ def cond(x, p=None):
0.70710678118654746
"""
- x = asarray(x) # in case we have a matrix
+ x = asarray(x) # in case we have a matrix
if p is None:
s = svd(x, compute_uv=False)
- return s[0]/s[-1]
+ return s[..., 0]/s[..., -1]
else:
- return norm(x, p)*norm(inv(x), p)
+ return norm(x, p, axis=(-2, -1)) * norm(inv(x), p, axis=(-2, -1))
def matrix_rank(M, tol=None):