def test_horizontal_projection(self): mat = self.bundle.total_space.random_uniform() vec = self.bundle.total_space.random_uniform() horizontal_vec = self.bundle.horizontal_projection(vec, mat) product = GeneralLinear.mul(horizontal_vec, GeneralLinear.inverse(mat)) is_horizontal = GeneralLinear.is_symmetric(product) self.assertTrue(is_horizontal)
def belongs(mat, atol=TOLERANCE): """Check if a matrix is symmetric and invertible.""" is_symmetric = GeneralLinear.is_symmetric(mat) eigvalues, _ = gs.linalg.eigh(mat) is_positive = gs.all(eigvalues > 0, axis=-1) belongs = gs.logical_and(is_symmetric, is_positive) return belongs