"""Metrics on homogeneous and symmetric spaces.
On a Riemannian homogeneous space, isometries act transitively, so the
geometry at any point is the geometry at a reference point moved by an
isometry. On a Riemannian symmetric space, these isometries can be chosen as
transvections, whose differentials give the parallel transport along
geodesics.
"""
import abc
from geomstats.geometry.riemannian_metric import RiemannianMetric
from geomstats.vectorization import repeat_out
[docs]
class HomogeneousMetric(RiemannianMetric, abc.ABC):
"""Metric on a Riemannian homogeneous space.
The geometry is only known at a reference point, through a metric at that
point, and is moved to any other base point by an isometry sending that
base point to the reference point.
The isometries are given by :meth:`isometry_to_reference` as
:class:`~geomstats.geometry.diffeo.PointedDiffeo` objects.
Parameters
----------
space : Manifold
Manifold.
at_reference : MetricAtPoint
Metric at the reference point.
signature : tuple
Signature of the metric.
"""
def __init__(self, space, at_reference, signature=None):
super().__init__(space, signature=signature)
self.at_reference = at_reference
[docs]
@abc.abstractmethod
def isometry_to_reference(self, base_point):
"""Get an isometry sending a base point to the reference point.
The reference point is the point of :attr:`at_reference`.
Parameters
----------
base_point : array-like, shape=[..., *point_shape]
Base point.
Returns
-------
isometry : geomstats.geometry.diffeo.PointedDiffeo
Isometry sending the base point to the reference point.
"""
[docs]
def inner_product(self, tangent_vec_a, tangent_vec_b, base_point):
"""Compute the inner product at a base point.
Parameters
----------
tangent_vec_a : array-like, shape=[..., *point_shape]
Tangent vector at base point.
tangent_vec_b : array-like, shape=[..., *point_shape]
Tangent vector at base point.
base_point : array-like, shape=[..., *point_shape]
Base point.
Returns
-------
inner_product : array-like, shape=[...,]
Inner product.
"""
isometry = self.isometry_to_reference(base_point)
return self.at_reference.inner_product(
isometry.tangent_at_anchor(tangent_vec_a),
isometry.tangent_at_anchor(tangent_vec_b),
)
[docs]
def exp(self, tangent_vec, base_point):
"""Compute the exponential map at a base point.
Parameters
----------
tangent_vec : array-like, shape=[..., *point_shape]
Tangent vector at base point.
base_point : array-like, shape=[..., *point_shape]
Base point.
Returns
-------
exp : array-like, shape=[..., *point_shape]
Point on the manifold.
"""
isometry = self.isometry_to_reference(base_point)
return isometry.inverse(
self.at_reference.exp(isometry.tangent_at_anchor(tangent_vec))
)
[docs]
def log(self, point, base_point):
"""Compute the logarithm map at a base point.
Parameters
----------
point : array-like, shape=[..., *point_shape]
Point on the manifold.
base_point : array-like, shape=[..., *point_shape]
Base point.
Returns
-------
log : array-like, shape=[..., *point_shape]
Tangent vector at base point.
"""
isometry = self.isometry_to_reference(base_point)
return isometry.inverse_tangent_at_reference(
self.at_reference.log(isometry(point))
)
[docs]
def squared_dist(self, point_a, point_b):
"""Compute the squared distance between two points.
Isometries preserve the distance, so it is computed from the
reference point, after sending the first point to it.
Parameters
----------
point_a : array-like, shape=[..., *point_shape]
Point on the manifold.
point_b : array-like, shape=[..., *point_shape]
Point on the manifold.
Returns
-------
sq_dist : array-like, shape=[...,]
Squared distance.
"""
isometry = self.isometry_to_reference(point_a)
return self.at_reference.squared_dist(isometry(point_b))
[docs]
def curvature(self, tangent_vec_a, tangent_vec_b, tangent_vec_c, base_point):
r"""Compute the Riemann curvature map at a base point.
Isometries preserve the curvature, so it is computed at the reference
point and sent back to the base point.
Parameters
----------
tangent_vec_a : array-like, shape=[..., *point_shape]
Tangent vector at base point.
tangent_vec_b : array-like, shape=[..., *point_shape]
Tangent vector at base point.
tangent_vec_c : array-like, shape=[..., *point_shape]
Tangent vector at base point.
base_point : array-like, shape=[..., *point_shape]
Base point.
Returns
-------
curvature : array-like, shape=[..., *point_shape]
Tangent vector at base point.
"""
isometry = self.isometry_to_reference(base_point)
return isometry.inverse_tangent_at_reference(
self.at_reference.curvature(
isometry.tangent_at_anchor(tangent_vec_a),
isometry.tangent_at_anchor(tangent_vec_b),
isometry.tangent_at_anchor(tangent_vec_c),
)
)
[docs]
def curvature_derivative(
self, tangent_vec_a, tangent_vec_b, tangent_vec_c, tangent_vec_d, base_point
):
r"""Compute the covariant derivative of the curvature at a base point.
Isometries preserve the covariant derivative of the curvature, so it
is computed at the reference point and sent back to the base point.
Parameters
----------
tangent_vec_a : array-like, shape=[..., *point_shape]
Tangent vector at base point.
tangent_vec_b : array-like, shape=[..., *point_shape]
Tangent vector at base point.
tangent_vec_c : array-like, shape=[..., *point_shape]
Tangent vector at base point.
tangent_vec_d : array-like, shape=[..., *point_shape]
Tangent vector at base point.
base_point : array-like, shape=[..., *point_shape]
Base point.
Returns
-------
curvature_derivative : array-like, shape=[..., *point_shape]
Tangent vector at base point.
"""
isometry = self.isometry_to_reference(base_point)
return isometry.inverse_tangent_at_reference(
self.at_reference.curvature_derivative(
isometry.tangent_at_anchor(tangent_vec_a),
isometry.tangent_at_anchor(tangent_vec_b),
isometry.tangent_at_anchor(tangent_vec_c),
isometry.tangent_at_anchor(tangent_vec_d),
)
)
[docs]
def sectional_curvature(self, tangent_vec_a, tangent_vec_b, base_point):
"""Compute the sectional curvature at a base point.
Isometries preserve the sectional curvature, so it is computed at the
reference point.
Parameters
----------
tangent_vec_a : array-like, shape=[..., *point_shape]
Tangent vector at base point.
tangent_vec_b : array-like, shape=[..., *point_shape]
Tangent vector at base point.
base_point : array-like, shape=[..., *point_shape]
Base point.
Returns
-------
sectional_curvature : array-like, shape=[...,]
Sectional curvature at base point.
"""
isometry = self.isometry_to_reference(base_point)
return self.at_reference.sectional_curvature(
isometry.tangent_at_anchor(tangent_vec_a),
isometry.tangent_at_anchor(tangent_vec_b),
)
[docs]
def injectivity_radius(self, base_point):
"""Compute the injectivity radius at a base point.
Isometries preserve the injectivity radius, so it is the one at the
reference point.
Parameters
----------
base_point : array-like, shape=[..., *point_shape]
Base point.
Returns
-------
radius : array-like, shape=[...,]
Injectivity radius.
"""
return repeat_out(
self._space.point_ndim, self.at_reference.injectivity_radius(), base_point
)
[docs]
class RiemannianSymmetricMetric(HomogeneousMetric, abc.ABC):
"""Metric on a Riemannian symmetric space.
The isometries returned by :meth:`isometry_to_reference` are
transvections: their differentials give the parallel transport along the
geodesics through their anchor.
"""
[docs]
def parallel_transport(
self, tangent_vec, base_point, direction=None, end_point=None
):
r"""Compute the parallel transport of a tangent vector.
The parallel transport along a geodesic is the differential of the
transvection along it. Denoting the base point by :math:`B`, the end
point by :math:`C` and by :math:`\phi_P` the transvection sending
:math:`P` to the reference point, this transvection is
:math:`\phi_B^{-1} \circ \phi_Y^{-1} \circ \phi_B` with
:math:`Y = \phi_B(C)`.
Parameters
----------
tangent_vec : array-like, shape=[..., *point_shape]
Tangent vector at base point to be transported.
base_point : array-like, shape=[..., *point_shape]
Base point.
direction : array-like, shape=[..., *point_shape]
Tangent vector at base point, along which the parallel transport
is computed.
end_point : array-like, shape=[..., *point_shape]
Point to transport to. Unused if `direction` is given.
Returns
-------
transported_tangent_vec : array-like, shape=[..., *point_shape]
Transported tangent vector at `exp_(base_point)(direction)`.
"""
if direction is not None:
end_point = self.exp(direction, base_point)
elif end_point is None:
raise ValueError(
"Either an end_point or a direction must be given to define the"
" geodesic along which to transport."
)
isometry = self.isometry_to_reference(base_point)
end_point_at_reference = isometry(end_point)
transported_at_reference = self.isometry_to_reference(
end_point_at_reference
).inverse_tangent_at_reference(isometry.tangent_at_anchor(tangent_vec))
return isometry.inverse_tangent(
transported_at_reference, image_point=end_point_at_reference
)