diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2017-09-30 11:01:02 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-30 11:01:02 -0600 |
commit | 697609cbb3b49dac0a61370ce7c8cd9b320fc43b (patch) | |
tree | 0daac2e4513d9b2442570662129c0137ec163162 | |
parent | 767744c86e1e4a27bf77f90a85f17e564c9b94ea (diff) | |
parent | 77c873d55c3de5ee62664090727a84a7ebeebc2c (diff) | |
download | numpy-697609cbb3b49dac0a61370ce7c8cd9b320fc43b.tar.gz |
Merge pull request #9796 from pv/cholesky-basictest
TST: linalg: add basic smoketest for cholesky
-rw-r--r-- | numpy/linalg/tests/test_linalg.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py index 8b3984883..0a6566bde 100644 --- a/numpy/linalg/tests/test_linalg.py +++ b/numpy/linalg/tests/test_linalg.py @@ -1507,6 +1507,30 @@ class TestQR(object): class TestCholesky(object): # TODO: are there no other tests for cholesky? + def test_basic_property(self): + # Check A = L L^H + shapes = [(1, 1), (2, 2), (3, 3), (50, 50), (3, 10, 10)] + dtypes = (np.float32, np.float64, np.complex64, np.complex128) + + for shape, dtype in itertools.product(shapes, dtypes): + np.random.seed(1) + a = np.random.randn(*shape) + if np.issubdtype(dtype, np.complexfloating): + a = a + 1j*np.random.randn(*shape) + + t = list(range(len(shape))) + t[-2:] = -1, -2 + + a = np.matmul(a.transpose(t).conj(), a) + a = np.asarray(a, dtype=dtype) + + c = np.linalg.cholesky(a) + + b = np.matmul(c, c.transpose(t).conj()) + assert_allclose(b, a, + err_msg="{} {}\n{}\n{}".format(shape, dtype, a, c), + atol=500 * a.shape[0] * np.finfo(dtype).eps) + def test_0_size(self): class ArraySubclass(np.ndarray): pass |