def testSimpleIndefinite(self): matrix = [[1., 2.], [2., 1.]] left = self.evaluate( simple_robustified_cholesky(matrix, tol=.1)) reconstruct = np.einsum('...ij,...kj->...ik', left, left) eigv, _ = self.evaluate(tf.linalg.eigh(reconstruct)) self.assertAllTrue(eigv > 0.)
def testSimpleIsCholeskyRandomPD(self): matrix = self._randomSymmetricMatrix(10, [2, 1, 3], 1e-6, 10., seed=42) chol, left = self.evaluate( (tf.linalg.cholesky(matrix), simple_robustified_cholesky(matrix))) self.assertAllClose(chol, left)