Skip to content

Commit 09bbde9

Browse files
authored
Merge pull request numpy#10085 from charris/backport-9796
TST: linalg: add basic smoketest for cholesky
2 parents 0136782 + f11c8cd commit 09bbde9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

numpy/linalg/tests/test_linalg.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,30 @@ def test_0_size(self):
14731473
class TestCholesky(object):
14741474
# TODO: are there no other tests for cholesky?
14751475

1476+
def test_basic_property(self):
1477+
# Check A = L L^H
1478+
shapes = [(1, 1), (2, 2), (3, 3), (50, 50), (3, 10, 10)]
1479+
dtypes = (np.float32, np.float64, np.complex64, np.complex128)
1480+
1481+
for shape, dtype in itertools.product(shapes, dtypes):
1482+
np.random.seed(1)
1483+
a = np.random.randn(*shape)
1484+
if np.issubdtype(dtype, np.complexfloating):
1485+
a = a + 1j*np.random.randn(*shape)
1486+
1487+
t = list(range(len(shape)))
1488+
t[-2:] = -1, -2
1489+
1490+
a = np.matmul(a.transpose(t).conj(), a)
1491+
a = np.asarray(a, dtype=dtype)
1492+
1493+
c = np.linalg.cholesky(a)
1494+
1495+
b = np.matmul(c, c.transpose(t).conj())
1496+
assert_allclose(b, a,
1497+
err_msg="{} {}\n{}\n{}".format(shape, dtype, a, c),
1498+
atol=500 * a.shape[0] * np.finfo(dtype).eps)
1499+
14761500
def test_0_size(self):
14771501
class ArraySubclass(np.ndarray):
14781502
pass

0 commit comments

Comments
 (0)