def test_integrated_exp_at_id(self): group = self.matrix_so3 metric = InvariantMetric(group=group) basis = metric.normal_basis(group.lie_algebra.basis) vector = gs.random.rand(2, len(basis)) tangent_vec = gs.einsum("...j,jkl->...kl", vector, basis) identity = self.matrix_so3.identity result = metric.exp(tangent_vec, identity, n_steps=100, step="rk4") expected = group.exp(tangent_vec, identity) self.assertAllClose(expected, result, atol=1e-5) result = metric.exp(tangent_vec, identity, n_steps=100, step="rk2") self.assertAllClose(expected, result, atol=1e-5)
def test_integrated_se3_exp_at_id(self, group): lie_algebra = group.lie_algebra metric = InvariantMetric(group=group) canonical_metric = group.left_canonical_metric basis = metric.normal_basis(lie_algebra.basis) vector = gs.random.rand(len(basis)) tangent_vec = gs.einsum("...j,jkl->...kl", vector, basis) identity = group.identity result = metric.exp(tangent_vec, identity, n_steps=100, step="rk4") expected = canonical_metric.exp(tangent_vec, identity) self.assertAllClose(expected, result, atol=1e-4) result = metric.exp(tangent_vec, identity, n_steps=100, step="rk2") self.assertAllClose(expected, result, atol=1e-4)
def test_integrated_parallel_transport(self, group, n, n_samples): metric = InvariantMetric(group=group) point = group.identity tan_b = Matrices(n + 1, n + 1).random_point(n_samples) tan_b = group.to_tangent(tan_b) # use a vector orthonormal to tan_b tan_a = Matrices(n + 1, n + 1).random_point(n_samples) tan_a = group.to_tangent(tan_a) coef = metric.inner_product(tan_a, tan_b) / metric.squared_norm(tan_b) tan_a -= gs.einsum("...,...ij->...ij", coef, tan_b) tan_b = gs.einsum("...ij,...->...ij", tan_b, 1.0 / metric.norm(tan_b, base_point=point)) tan_a = gs.einsum("...ij,...->...ij", tan_a, 1.0 / metric.norm(tan_a, base_point=point)) expected = group.left_canonical_metric.parallel_transport( tan_a, point, tan_b) result, end_point_result = metric.parallel_transport( tan_a, point, tan_b, n_steps=20, step="rk4", return_endpoint=True) expected_end_point = metric.exp(tan_b, point, n_steps=20) self.assertAllClose(end_point_result, expected_end_point, atol=gs.atol * 1000) self.assertAllClose(expected, result, atol=gs.atol * 1000)
def test_integrated_se3_exp_at_id(self): group = self.matrix_se3 lie_algebra = group.lie_algebra metric = InvariantMetric(group=group) canonical_metric = group.left_canonical_metric basis = metric.orthonormal_basis(lie_algebra.basis) vector = gs.random.rand(len(basis)) tangent_vec = gs.einsum('...j,jkl->...kl', vector, basis) identity = self.matrix_se3.identity result = metric.exp(tangent_vec, identity, n_steps=100, step='rk4') expected = canonical_metric.exp(tangent_vec, identity) self.assertAllClose(expected, result, atol=1e-5) result = metric.exp(tangent_vec, identity, n_steps=100, step='rk2') self.assertAllClose(expected, result, atol=1e-5)
def test_integrated_se3_exp(self): group = self.matrix_se3 lie_algebra = group.lie_algebra metric = InvariantMetric(group=group) canonical_metric = group.left_canonical_metric basis = metric.normal_basis(lie_algebra.basis) point = group.random_point() vector = gs.random.rand(len(basis)) tangent_vec = gs.einsum("...j,jkl->...kl", vector, basis) tangent_vec = group.tangent_translation_map(point)(tangent_vec) result = metric.exp(tangent_vec, point, n_steps=100, step="rk4") expected = canonical_metric.exp(tangent_vec, point) self.assertAllClose(expected, result) result = metric.exp(tangent_vec, point, n_steps=100, step="rk2") self.assertAllClose(expected, result, atol=4e-5)
def test_integrated_exp_and_log_at_id(self): group = self.matrix_so3 metric = InvariantMetric(group=group) basis = group.lie_algebra.basis vector = gs.random.rand(2, len(basis)) tangent_vec = gs.einsum("...j,jkl->...kl", vector, basis) identity = self.matrix_so3.identity exp = metric.exp(tangent_vec, identity, n_steps=100, step="rk4") result = metric.log(exp, identity, n_steps=15, step="rk4", verbose=False) self.assertAllClose(tangent_vec, result, atol=1e-5)