def pointwise_inner_product(self, tangent_vec_a, tangent_vec_b, base_curve): """Compute the pointwise inner product of pair of tangent vectors. Compute the point-wise inner-product between two tangent vectors at a base curve. Parameters ---------- tangent_vec_a : array-like, shape=[..., n_sampling_points, ambient_dim] Tangent vector to discrete curve. tangent_vec_b : array-like, shape=[..., n_sampling_points, ambient_dim] Tangent vector to discrete curve. base_curve : array-like, shape=[..., n_sampling_points, ambient_dim] Point representing a discrete curve. Returns ------- inner_prod : array-like, shape=[..., n_sampling_points] Point-wise inner-product. """ def inner_prod_aux(vec_a, vec_b, curve): inner_prod = self.ambient_metric.inner_product(vec_a, vec_b, curve) return gs.squeeze(inner_prod) inner_prod = gs.vectorize( (tangent_vec_a, tangent_vec_b, base_curve), inner_prod_aux, dtype=gs.float32, multiple_args=True, signature='(i,j),(i,j),(i,j)->(i)') return inner_prod
def pointwise_inner_product(self, tangent_vec_a, tangent_vec_b, base_curve): """ Compute the inner products of the components of a (series of) pair(s) of tangent vectors at (a) base curve(s). """ base_curve = gs.to_ndarray(base_curve, to_ndim=3) tangent_vec_a = gs.to_ndarray(tangent_vec_a, to_ndim=3) tangent_vec_b = gs.to_ndarray(tangent_vec_b, to_ndim=3) n_tangent_vecs = tangent_vec_a.shape[0] n_sampling_points = tangent_vec_a.shape[1] inner_prod = gs.zeros([n_tangent_vecs, n_sampling_points]) def inner_prod_aux(vec_a, vec_b, curve): inner_prod = self.embedding_metric.inner_product( vec_a, vec_b, curve) return gs.squeeze(inner_prod) inner_prod = gs.vectorize((tangent_vec_a, tangent_vec_b, base_curve), lambda x, y, z: inner_prod_aux(x, y, z), dtype=gs.float32, multiple_args=True, signature='(i,j),(i,j),(i,j)->(i)') return inner_prod
def landmarks_on_geodesic(t): t = gs.cast(t, gs.float32) t = gs.to_ndarray(t, to_ndim=1) tangent_vecs = gs.einsum("...,...ij->...ij", t, initial_tangent_vec) def point_on_landmarks(tangent_vec): if gs.ndim(tangent_vec) < 2: raise RuntimeError exp = self.exp(tangent_vec=tangent_vec, base_point=initial_point) return exp landmarks_at_time_t = gs.vectorize(tangent_vecs, point_on_landmarks, signature="(i,j)->(i,j)") return landmarks_at_time_t
def landmarks_on_geodesic(t): t = gs.cast(t, gs.float32) t = gs.to_ndarray(t, to_ndim=1) t = gs.to_ndarray(t, to_ndim=2, axis=1) new_initial_landmarks = gs.to_ndarray(initial_landmarks, to_ndim=landmarks_ndim + 1) new_initial_tangent_vec = gs.to_ndarray(initial_tangent_vec, to_ndim=landmarks_ndim + 1) tangent_vecs = gs.einsum('il,nkm->ikm', t, new_initial_tangent_vec) def point_on_landmarks(tangent_vec): assert gs.ndim(tangent_vec) >= 2 exp = self.exp(tangent_vec=tangent_vec, base_landmarks=new_initial_landmarks) return exp landmarks_at_time_t = gs.vectorize(tangent_vecs, point_on_landmarks, signature='(i,j)->(i,j)') return landmarks_at_time_t
def curve_on_geodesic(t): t = gs.cast(t, gs.float32) t = gs.to_ndarray(t, to_ndim=1) t = gs.to_ndarray(t, to_ndim=2, axis=1) new_initial_curve = gs.to_ndarray(initial_curve, to_ndim=curve_ndim + 1) new_initial_tangent_vec = gs.to_ndarray(initial_tangent_vec, to_ndim=curve_ndim + 1) tangent_vecs = gs.einsum('il,nkm->ikm', t, new_initial_tangent_vec) def point_on_curve(tangent_vec): assert gs.ndim(tangent_vec) >= 2 exp = self.exp(tangent_vec=tangent_vec, base_curve=new_initial_curve) return exp curve_at_time_t = gs.vectorize(tangent_vecs, point_on_curve, signature='(i,j)->(i,j)') return curve_at_time_t
def landmarks_on_geodesic(t): t = gs.cast(t, gs.float32) t = gs.to_ndarray(t, to_ndim=1) t = gs.to_ndarray(t, to_ndim=2, axis=1) new_initial_landmarks = gs.to_ndarray(initial_landmarks, to_ndim=landmarks_ndim + 1) new_initial_tangent_vec = gs.to_ndarray(initial_tangent_vec, to_ndim=landmarks_ndim + 1) tangent_vecs = gs.einsum("il,nkm->ikm", t, new_initial_tangent_vec) def point_on_landmarks(tangent_vec): if gs.ndim(tangent_vec) < 2: raise RuntimeError exp = self.exp(tangent_vec=tangent_vec, base_point=new_initial_landmarks) return exp landmarks_at_time_t = gs.vectorize(tangent_vecs, point_on_landmarks, signature="(i,j)->(i,j)") return landmarks_at_time_t