def test_chol(self,thr=1e-8): """ Verify Cholesky decomposition. """ n = 31 A = np.random.rand(n,n) A = np.dot(A.T,A) L = inf.chol(A) self.assertLessEqual(np.linalg.norm(np.dot(L,L.T)-A),thr) self.assertLessEqual(np.linalg.norm(np.tril(L)-L),thr)
def test_solve_chol(self,thr=1e-8): """ Verify Cholesky-based solution of linear equations. """ n = 31 A = np.random.rand(n,n) A = np.dot(A.T,A) B = np.random.randn(n,4) X = np.linalg.solve(A,B) Y = inf.solve_chol(inf.chol(A),B) self.assertLessEqual(np.linalg.norm(X-Y),thr)