diff options
author | aarchiba <peridot.faceted@gmail.com> | 2008-04-08 18:49:18 +0000 |
---|---|---|
committer | aarchiba <peridot.faceted@gmail.com> | 2008-04-08 18:49:18 +0000 |
commit | e4e3018081ad2ab92850ca246ec25dda754c0184 (patch) | |
tree | 15bdfee6fe547da703567d1a903e8bcdaa7c560b /numpy/linalg/tests | |
parent | 2ba8132b518e08c6b25e54df0a025cf9aa006f06 (diff) | |
download | numpy-e4e3018081ad2ab92850ca246ec25dda754c0184.tar.gz |
Added function for computing condition number, with tests and docs; closes #622.
Diffstat (limited to 'numpy/linalg/tests')
-rw-r--r-- | numpy/linalg/tests/test_linalg.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py index 5321ae7c5..7d2390980 100644 --- a/numpy/linalg/tests/test_linalg.py +++ b/numpy/linalg/tests/test_linalg.py @@ -4,7 +4,7 @@ from numpy.testing import * set_package_path() from numpy import array, single, double, csingle, cdouble, dot, identity, \ - multiply, atleast_2d + multiply, atleast_2d, inf from numpy import linalg from linalg import matrix_power restore_path() @@ -73,6 +73,21 @@ class TestSVD(LinalgTestCase): u, s, vt = linalg.svd(a, 0) assert_almost_equal(a, dot(u*s, vt)) +class TestCondSVD(LinalgTestCase): + def do(self, a, b): + s = linalg.svd(a, compute_uv=False) + old_assert_almost_equal(s[0]/s[-1], linalg.cond(a), decimal=5) + +class TestCond2(LinalgTestCase): + def do(self, a, b): + s = linalg.svd(a, compute_uv=False) + old_assert_almost_equal(s[0]/s[-1], linalg.cond(a,2), decimal=5) + +class TestCondInf(NumpyTestCase): + def test(self): + A = array([[1.,0,0],[0,-2.,0],[0,0,3.]]) + assert_almost_equal(linalg.cond(A,inf),3.) + class TestPinv(LinalgTestCase): def do(self, a, b): a_ginv = linalg.pinv(a) |