geomstats.variants.geometry package#
Submodules#
geomstats.variants.geometry.complex_poincare_disk module#
Variants of the metric on the complex Poincare disk.
- class geomstats.variants.geometry.complex_poincare_disk.PullbackComplexPoincareDiskMetric(space)[source]#
Bases:
PullbackDiffeoMetricMetric on the complex Poincare disk as a pullback metric.
Variant of
geomstats.geometry.complex_poincare_disk.ComplexPoincareDiskMetricwithout its closed forms: the geometry is pulled back from the two-dimensional Poincare ball, with its metric scaled by 1/4, through the real coordinates of the complex disk.- Parameters:
space (ComplexPoincareDisk) – Manifold.
geomstats.variants.geometry.discrete_curves module#
Non-vectorized dynamic programming aligner for discrete curves.
- class geomstats.variants.geometry.discrete_curves.DynamicProgrammingAligner(total_space, n_space_grid=100, max_slope=6)[source]#
Bases:
AlignerAlgorithmAlign two curves through dynamic programming.
Variant of
geomstats.geometry.discrete_curves.DynamicProgrammingAlignerwith a non-vectorized implementation.Find the reparametrization gamma of end_curve that minimizes the distance between initial_curve and end_curve reparametrized by gamma, and output the corresponding distance, using a dynamic programming algorithm.
The objective can be expressed in terms of square root velocity (SRV) representations: it is equivalent to finding the gamma that maximizes the L2 scalar product between \(initial_{srv}\) and \(end_{srv}@\gamma\), where \(initial_{srv}\) is the SRV representation of the initial curve and \(end_{srv}@\gamma\) is the SRV representation of the end curve reparametrized by \(\gamma\), i.e
\[end_{srv}@\gamma(t) = end_{srv}(\gamma(t))\cdot|\gamma(t)|^\frac{1}{2}\]The dynamic programming algorithm assumes that for every subinterval \(\left[\frac{i}{n},\frac{i+1}{n}\right]\) of \(\left[0,1\right]\), gamma is linear.
- Parameters:
total_space (Manifold) – Total space with reparametrizations fiber bundle structure.
n_space_grid (int) – Number of sampling points of the unit interval.
max_slope (int) – Maximum slope allowed for a reparametrization.
References
[WAJ2007]M. Washington, S. Anuj & H. Joshi, “On Shape of Plane Elastic Curves”, in International Journal of Computer Vision. 73(3):307-324, 2007.
- align(point, base_point, return_sdist=False)[source]#
Align point to base point.
- Parameters:
point (array-like, shape=[…, k_sampling_points - 1, ambient_dim]) – Discrete curve to align.
base_point (array-like, shape=[…, k_sampling_points - 1, ambient_dim]) – Reference discrete curve.
return_sdist (bool) – If True, also returns squared distance.
- Returns:
aligned (array-like, shape=[…, k_sampling_points - 1, ambient_dim]) – Curve reparametrized in an optimal way with respect to reference curve.
squared_dist (array, shape=[…,]) – Quotient distance between point and base point. If return_sdist is True.
geomstats.variants.geometry.functions module#
Variants of the metric on the Hilbert sphere.
- class geomstats.variants.geometry.functions.TrapezoidHilbertSphereMetric(space)[source]#
Bases:
RiemannianMetricMetric on the Hilbert sphere with closed forms.
Variant of
geomstats.geometry.functions.HilbertSphereMetricthat computes the inner product with the trapezoidal rule, on the domain rescaled to \([0, 1]\), and the exponential, the logarithm, the parallel transport and the injectivity radius with the closed forms of the sphere, instead of pulling back the metric of the unit sphere.- Parameters:
space (HilbertSphere) – Manifold.
- exp(tangent_vec, base_point)[source]#
Compute the Riemannian exponential of a tangent vector.
- Parameters:
tangent_vec (array-like, shape=[…, n_samples]) – Tangent vector at a base point.
base_point (array-like, shape=[…, n_samples]) – Point on the hypersphere.
- Returns:
exp (array-like, shape=[…, n_samples]) – Point on the hypersphere equal to the Riemannian exponential of tangent_vec at the base point.
- injectivity_radius(base_point=None)[source]#
Compute the radius of the injectivity domain.
Geodesics are great circles, so that the cut point of a point is its antipode, and the radius is pi everywhere.
- Parameters:
base_point (array-like, shape=[…, n_samples]) – Point on the hypersphere.
- Returns:
radius (array-like, shape=[…,]) – Injectivity radius.
- inner_product(tangent_vec_a, tangent_vec_b, base_point=None)[source]#
Compute the inner-product of two tangent vectors at a base point.
- Parameters:
tangent_vec_a (array-like, shape=[…, n_samples]) – First tangent vector at base point.
tangent_vec_b (array-like, shape=[…, n_samples]) – Second tangent vector at base point.
base_point (array-like, shape=[…, n_samples], optional) – Point on the hypersphere.
- Returns:
inner_prod (array-like, shape=[…,]) – Inner-product of the two tangent vectors.
- log(point, base_point)[source]#
Compute the Riemannian logarithm of a point.
- Parameters:
point (array-like, shape=[…, n_samples]) – Point on the hypersphere.
base_point (array-like, shape=[…, n_samples]) – Point on the hypersphere.
- Returns:
log (array-like, shape=[…, n_samples]) – Tangent vector at the base point equal to the Riemannian logarithm of point at the base point.
- parallel_transport(tangent_vec, base_point, direction=None, end_point=None)[source]#
Compute the parallel transport of a tangent vector.
The geodesic from \(x\) with direction \(v\) stays in the plane spanned by \(x\) and \(u = v / \|v\|\), in which it rotates by the angle \(\theta = \|v\|\). The component of the tangent vector \(w\) along \(u\) rotates with it, and the orthogonal one is unchanged:
\[P(w) = w - \langle w, u \rangle (\sin(\theta) x + (1 - \cos(\theta)) u)\]- Parameters:
tangent_vec (array-like, shape=[…, n_samples]) – Tangent vector at base point to be transported.
base_point (array-like, shape=[…, n_samples]) – Point on the hypersphere.
direction (array-like, shape=[…, n_samples]) – Tangent vector at base point, along which the parallel transport is computed.
end_point (array-like, shape=[…, n_samples]) – Point on the hypersphere to transport to. Unused if
directionis given.
- Returns:
transported_tangent_vec (array-like, shape=[…, n_samples]) – Transported tangent vector at
exp_(base_point)(direction).
geomstats.variants.geometry.poincare_ball module#
Poincare ball metric given only by its metric matrix.
- class geomstats.variants.geometry.poincare_ball.PoincareBallMetric(space, signature=None)[source]#
Bases:
CoordinateRiemannianMetricPoincare ball metric given only by its metric matrix.
The Christoffel symbols and the curvature tensors are computed from the metric matrix with automatic differentiation, instead of the closed forms of
geomstats.geometry.poincare_ball.PoincareBallMetric.
geomstats.variants.geometry.poincare_half_space module#
Variants of the metric on the Poincare half-space.
- class geomstats.variants.geometry.poincare_half_space.PullbackPoincareHalfSpaceMetric(space)[source]#
Bases:
CoordinatePullbackDiffeoMetricHyperbolic metric on the Poincare half-space as a pullback metric.
Variant of
geomstats.geometry.poincare_half_space.PoincareHalfSpaceMetricwithout its closed forms: the Christoffel symbols and the curvature tensors are computed from the pullback metric matrix with automatic differentiation.- Parameters:
space (PoincareHalfSpace) – Manifold.
geomstats.variants.geometry.positive_lower_triangular_matrices module#
Matrix logarithm on unit-diagonal lower triangular matrices with logm and expm.
- class geomstats.variants.geometry.positive_lower_triangular_matrices.LowerMatrixLog[source]#
Bases:
DiffeoMatrix logarithm diffeomorphism.
Variant of
geomstats.geometry.positive_lower_triangular_matrices.LowerMatrixLogcomputed with the general matrix logarithm and exponential.A diffeomorphism between the lower triangular matrices with unit diagonal and strictly lower triangular matrices.
Notes
The differentials use that, for a matrix function \(f\),
\[\begin{split}f\left(\begin{bmatrix} X & E \\ 0 & X \end{bmatrix}\right) = \begin{bmatrix} f(X) & d_X f(E) \\ 0 & f(X) \end{bmatrix}\end{split}\]- static inverse(image_point)[source]#
Compute the matrix exponential.
- Parameters:
image_point (array_like, shape=[…, n, n]) – Strictly lower triangular matrix.
- Returns:
exponential (array_like, shape=[…, n, n]) – Lower triangular matrix with unit diagonal.
- inverse_tangent(image_tangent_vec, image_point=None, base_point=None)[source]#
Inverse tangent diffeomorphism at image point.
- Parameters:
image_tangent_vec (array-like, shape=[…, n, n]) – Image tangent vector at image point.
image_point (array-like, shape=[…, n, n]) – Image point.
base_point (array-like, shape=[…, n, n]) – Base point.
- Returns:
tangent_vec (array-like, shape=[…, n, n]) – Tangent vector at base point.
- tangent(tangent_vec, base_point=None, image_point=None)[source]#
Tangent diffeomorphism at base point.
- Parameters:
tangent_vec (array-like, shape=[…, n, n]) – Tangent vector at base point.
base_point (array-like, shape=[…, n, n]) – Base point.
image_point (array-like, shape=[…, n, n]) – Image point.
- Returns:
image_tangent_vec (array-like, shape=[…, n, n]) – Image tangent vector at image of the base point.
geomstats.variants.geometry.positive_reals module#
Variants of the logarithmic metric on the positive reals.
- class geomstats.variants.geometry.positive_reals.LogMetric(space, signature=None)[source]#
Bases:
CoordinateRiemannianMetricLogarithmic metric on the positive reals given only by its metric matrix.
The Christoffel symbols and the curvature tensors are computed from the metric matrix with automatic differentiation, instead of the closed forms of
geomstats.geometry.positive_reals.LogMetric.
- class geomstats.variants.geometry.positive_reals.PowerMetric(space, power)[source]#
Bases:
CoordinateRiemannianMetricPower-Euclidean metric on the positive reals given by its metric matrix.
The Christoffel symbols and the curvature tensors are computed from the metric matrix with automatic differentiation, instead of the closed forms of
geomstats.geometry.positive_reals.PowerMetric.- Parameters:
space (PositiveReals) – Manifold.
power (float) – Non-zero power.
- class geomstats.variants.geometry.positive_reals.PullbackLogMetric(space)[source]#
Bases:
CoordinatePullbackDiffeoMetricLogarithmic metric on the positive reals as a pullback metric.
Variant of
geomstats.geometry.positive_reals.LogMetricwithout its closed forms: the Christoffel symbols and the curvature tensors are computed from the pullback metric matrix with automatic differentiation.- Parameters:
space (PositiveReals) – Manifold.
- class geomstats.variants.geometry.positive_reals.PullbackPowerMetric(space, power)[source]#
Bases:
CoordinatePullbackDiffeoMetricPower-Euclidean metric on the positive reals as a pullback metric.
Variant of
geomstats.geometry.positive_reals.PowerMetricwithout its closed forms: the Christoffel symbols and the curvature tensors are computed from the pullback metric matrix with automatic differentiation.- Parameters:
space (PositiveReals) – Manifold.
power (float) – Non-zero power.
geomstats.variants.geometry.spd_matrices module#
Bures-Wasserstein metric on SPD matrices as a quotient metric.
Importing this module registers the quotient structure of the positive general linear group under the special orthogonal compose action, so that PositiveGeneralLinear.equip_with_quotient induces the Bures-Wasserstein metric on SPD matrices.
- class geomstats.variants.geometry.spd_matrices.PositiveGeneralLinearGramBundle(total_space)[source]#
Bases:
FiberBundleGram map bundle from the positive general linear group to SPD matrices.
The Gram map \(X \mapsto XX^T\) is invariant under the right action of the special orthogonal group, and induces a diffeomorphism from the quotient \(GL^+(n) / SO(n)\) to SPD matrices.
Variant of
geomstats.geometry.spd_matrices.SPDBuresWassersteinMetricobtained as the quotient of the Frobenius metric on the positive general linear group.- Parameters:
total_space (PositiveGeneralLinear) – Total space.
- align(point, base_point)[source]#
Align point to base point.
Denoting point by \(X\) and base_point by \(Y\), find the rotation \(R \in SO(n)\) minimizing \(\|XR - Y\|_F\). This is the orthogonal Procrustes problem: with the singular value decomposition \(X^T Y = U \Sigma V^T\), the minimizer is \(R = UV^T\).
Since \(\det(X^T Y) > 0\) on the positive general linear group, \(\det(UV^T) = 1\), so no determinant correction is needed.
- Parameters:
point (array-like, shape=[…, n, n]) – Point of the total space to align.
base_point (array-like, shape=[…, n, n]) – Point of the total space.
- Returns:
aligned_point (array-like, shape=[…, n, n]) – Point of the fiber of point closest to base_point.
- horizontal_lift(tangent_vec, base_point=None, fiber_point=None)[source]#
Lift a tangent vector to a horizontal vector in the total space.
Denoting tangent_vec by \(W\), base_point by \(P\) and fiber_point by \(X\), the horizontal lift is
\[V = SX\]where \(S\) is the symmetric solution of the Sylvester equation \(PS + SP = W\).
- Parameters:
tangent_vec (array-like, shape=[…, n, n]) – Tangent vector to SPD matrices at base_point.
base_point (array-like, shape=[…, n, n]) – SPD matrix. Optional, default: None. In this case, fiber_point must be given, and riemannian_submersion is used to compute base_point.
fiber_point (array-like, shape=[…, n, n]) – Point of the total space in the fiber above base_point. Optional, default: None. In this case, lift is used to compute fiber_point.
- Returns:
horizontal_lift (array-like, shape=[…, n, n]) – Horizontal tangent vector to the total space at fiber_point.
- static lift(point)[source]#
Lift an SPD matrix to the total space with the Cholesky factor.
The Cholesky factor is lower triangular with positive diagonal, so it has a positive determinant.
- Parameters:
point (array-like, shape=[…, n, n]) – SPD matrix.
- Returns:
lift (array-like, shape=[…, n, n]) – Point of the total space.
- static riemannian_submersion(point)[source]#
Project a point to SPD matrices with the Gram map.
\[\pi(X) = XX^T\]- Parameters:
point (array-like, shape=[…, n, n]) – Point of the total space.
- Returns:
projection (array-like, shape=[…, n, n]) – SPD matrix.
- tangent_riemannian_submersion(tangent_vec, base_point)[source]#
Project a tangent vector to SPD matrices.
Differential of the Gram map:
\[d\pi_X(V) = XV^T + VX^T\]- Parameters:
tangent_vec (array-like, shape=[…, n, n]) – Tangent vector to the total space at base_point.
base_point (array-like, shape=[…, n, n]) – Point of the total space.
- Returns:
projection (array-like, shape=[…, n, n]) – Symmetric matrix, tangent to SPD matrices at the projection of base_point.
- class geomstats.variants.geometry.spd_matrices.QuotientSPDBuresWassersteinMetric(space, total_space=None)[source]#
Bases:
QuotientMetricBures-Wasserstein metric on SPD matrices as a quotient metric.
Variant of
geomstats.geometry.spd_matrices.SPDBuresWassersteinMetricobtained as the quotient of the Frobenius metric on the positive general linear group by the right action of the special orthogonal group.- Parameters:
space (SPDMatrices) – Base manifold.
total_space (PositiveGeneralLinear) – Total space. Optional, default: None. In this case, it is equipped with the Frobenius metric and the special orthogonal compose action.
Module contents#
Alternative implementations of geometries in geomstats.geometry.