def test_split_horizontal_vertical( self, times, n_discretized_curves, curve_a, curve_b ): """Test split horizontal vertical. Check that horizontal and vertical parts of any tangent vector are othogonal with respect to the SRVMetric inner product, and check vectorization. """ srv_metric_r3 = SRVMetric(r3) quotient_srv_metric_r3 = DiscreteCurves(ambient_manifold=r3).quotient_srv_metric geod = srv_metric_r3.geodesic(initial_curve=curve_a, end_curve=curve_b) geod = geod(times) tangent_vec = n_discretized_curves * (geod[1, :, :] - geod[0, :, :]) ( tangent_vec_hor, tangent_vec_ver, _, ) = quotient_srv_metric_r3.split_horizontal_vertical(tangent_vec, curve_a) result = srv_metric_r3.inner_product(tangent_vec_hor, tangent_vec_ver, curve_a) expected = 0.0 self.assertAllClose(result, expected, atol=1e-4) tangent_vecs = n_discretized_curves * (geod[1:] - geod[:-1]) _, _, result = quotient_srv_metric_r3.split_horizontal_vertical( tangent_vecs, geod[:-1] ) expected = [] for i in range(n_discretized_curves - 1): _, _, res = quotient_srv_metric_r3.split_horizontal_vertical( tangent_vecs[i], geod[i] ) expected.append(res) expected = gs.stack(expected) self.assertAllClose(result, expected)
def test_horizontal_geodesic(self, n_sampling_points, curve_a, n_times): """Test horizontal geodesic. Check that the time derivative of the geodesic is horizontal at all time. """ curve_b = gs.transpose( gs.stack( ( gs.zeros(n_sampling_points), gs.zeros(n_sampling_points), gs.linspace(1.0, 0.5, n_sampling_points), ) ) ) quotient_srv_metric_r3 = DiscreteCurves(ambient_manifold=r3).quotient_srv_metric horizontal_geod_fun = quotient_srv_metric_r3.horizontal_geodesic( curve_a, curve_b ) times = gs.linspace(0.0, 1.0, n_times) horizontal_geod = horizontal_geod_fun(times) velocity_vec = n_times * (horizontal_geod[1:] - horizontal_geod[:-1]) _, _, vertical_norms = quotient_srv_metric_r3.split_horizontal_vertical( velocity_vec, horizontal_geod[:-1] ) result = gs.sum(vertical_norms**2, axis=1) ** (1 / 2) expected = gs.zeros(n_times - 1) self.assertAllClose(result, expected, atol=1e-3)