def test_matrix_util(self): A = np.array([[1, 2], [3, 4]]) self.assertFalse(mut.IsSymmetric(matrix=A)) self.assertFalse(mut.IsSymmetric(matrix=A, precision=0)) self.assertTrue(mut.IsSymmetric(np.eye(3), 0.)) self.assertFalse(mut.IsPositiveDefinite(matrix=A, tolerance=0)) self.assertTrue(mut.IsPositiveDefinite(A.dot(A.T)))
def test_matrix_util(self): A = np.array([[1, 2], [3, 4]]) self.assertFalse(mut.IsSymmetric(matrix=A)) self.assertFalse(mut.IsSymmetric(matrix=A, precision=0)) self.assertTrue(mut.IsSymmetric(np.eye(3), 0.)) self.assertFalse(mut.IsPositiveDefinite(matrix=A, tolerance=0)) self.assertTrue(mut.IsPositiveDefinite(A.dot(A.T))) lower_triangular = np.array([1, 2, 3, 4, 5, 6.]) symmetric_mat = mut.ToSymmetricMatrixFromLowerTriangularColumns( lower_triangular_columns=lower_triangular) np.testing.assert_array_equal( symmetric_mat, np.array([[1, 2, 3], [2, 4, 5], [3, 5, 6]]))