Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
2 changes: 1 addition & 1 deletion geomstats/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def load_mammals(file_path=MAMMALS_PATH):
----------
.. [Franz2015] Franz, M., Altmann, J., & Alberts, S. C.
"Knockouts of high-ranking males have limited impact on baboon social networks."
Current Zoology, 61(1), 107-113, 2015.
Current Zoology, 61(1), 107-113, 2015.
.. [Rossi2015] Rossi, R., & Ahmed, N.
"The network data repository with interactive graph analytics and
visualization." In Twenty-ninth AAAI conference on artificial intelligence, 2015
Expand Down
9 changes: 4 additions & 5 deletions geomstats/distributions/lognormal.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,15 @@ class LogNormal:
space : Manifold obj, {Euclidean(n), SPDMatrices(n)}
Manifold to sample over. Manifold should
be instance of Euclidean or SPDMatrices.
mean : array-like,
shape=[dim] if space is Euclidean Space
mean : array-like, \
shape=[dim] if space is Euclidean Space \
shape=[n, n] if space is SPD Manifold
Mean of the distribution.
cov : array-like,
shape=[dim, dim] if space is Euclidean Space
cov : array-like, \
shape=[dim, dim] if space is Euclidean Space \
shape=[n*(n+1)/2, n*(n+1)/2] if space is SPD Manifold
Covariance of the distribution.


Example
--------
>>> import geomstats.backend as gs
Expand Down
26 changes: 16 additions & 10 deletions geomstats/geometry/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,30 +357,28 @@ def ladder_parallel_transport(
def riemann_tensor(self, base_point):
r"""Compute Riemannian tensor at base_point.

In the literature the riemannian curvature tensor is noted :math:`R_{ijk}^l`.
In the literature the Riemannian curvature tensor is noted :math:`R_{ijk}^l`.

Following tensor index convention (ref. Wikipedia), we have:
:math:`R_{ijk}^l = dx^l(R(X_j, X_k)X_i)`

which gives :math:`R_{ijk}^lk` as a sum of four terms:
:math:`R_{ijk}^l =
:math:`\partial_j \Gamma^l_{ki}`
:math:`- \partial_k \Gamma^l_{ji}`
:math:`+ \Gamma^l_{jm} \Gamma^m_{ki}`
:math:`- \Gamma^l_{km} \Gamma^m_{ji}`
which gives :math:`R_{ijk}^l` as a sum of four terms:

.. math::
\partial_j \Gamma^l_{ki} - \partial_k \Gamma^l_{ji}
+ \Gamma^l_{jm} \Gamma^m_{ki} - \Gamma^l_{km} \Gamma^m_{ji}

Note that geomstats puts the contravariant index on
the first dimension of the Christoffel symbols.

Parameters
----------
base_point : array-like, shape=[..., dim]
base_point : array-like, shape=[..., dim]
Point on the manifold.

Returns
-------
riemann_curvature : array-like, shape=[..., dim, dim,
dim, dim]
riemann_curvature : array-like, shape=[..., dim, dim, dim, dim]
riemann_tensor[...,i,j,k,l] = R_{ijk}^l
Riemannian tensor curvature,
with the contravariant index on the last dimension.
Expand Down Expand Up @@ -408,9 +406,11 @@ def curvature(self, tangent_vec_a, tangent_vec_b, tangent_vec_c, base_point):
r"""Compute the Riemann curvature map R.

For three tangent vectors at base point :math:`P`:

- :math:`X|_P = tangent\_vec\_a`,
- :math:`Y|_P = tangent\_vec\_b`,
- :math:`Z|_P = tangent\_vec\_c`,

the curvature(X, Y, Z, P) is defined by
:math:`R(X,Y)Z = \nabla_X \nabla_Y Z - \nabla_Y \nabla_X Z - \nabla_[X, Y]Z`.

Expand Down Expand Up @@ -471,8 +471,10 @@ def directional_curvature(self, tangent_vec_a, tangent_vec_b, base_point):
r"""Compute the directional curvature (tidal force operator).

For two tangent vectors at base_point :math:`P`:

- :math:`X|_P = tangent\_vec\_a`,
- :math:`Y|_P = tangent\_vec\_b`,

the directional curvature, better known
in relativity as the tidal force operator,
is defined by
Expand Down Expand Up @@ -505,10 +507,12 @@ def curvature_derivative(
r"""Compute the covariant derivative of the curvature.

For four tangent vectors at base_point :math:`P`:

- :math:`H|_P = tangent\_vec\_a`,
- :math:`X|_P = tangent\_vec\_b`,
- :math:`Y|_P = tangent\_vec\_c`,
- :math:`Z|_P = tangent\_vec\_d`,

the covariant derivative of the curvature is defined as:
:math:`(\nabla_H R)(X, Y) Z |_P`.

Expand Down Expand Up @@ -540,8 +544,10 @@ def directional_curvature_derivative(
r"""Compute the covariant derivative of the directional curvature.

For tangent vector fields at base_point :math:`P`:

- :math:`X|_P = tangent\_vec\_a`,
- :math:`Y|_P = tangent\_vec\_b`,

the covariant derivative (in the direction `X`)
:math:`(\nabla_X R_Y)(X) |_P = (\nabla_X R)(Y, X) Y |_P` of the
directional curvature (in the direction `Y`)
Expand Down
4 changes: 2 additions & 2 deletions geomstats/geometry/diffeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Diffeo:

Let :math:`f` be the diffeomorphism
:math:`f: M \rightarrow N` of the manifold
:math:`M` into the manifold `N`.
:math:`M` into the manifold :math:`N`.
"""

@abc.abstractmethod
Expand All @@ -34,7 +34,7 @@ def diffeomorphism(self, base_point):
def inverse_diffeomorphism(self, image_point):
r"""Inverse diffeomorphism at base point.

:math:`f^-1: N \rightarrow M`
:math:`f^{-1}: N \rightarrow M`

Parameters
----------
Expand Down
24 changes: 17 additions & 7 deletions geomstats/geometry/discrete_curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ def inverse_diffeomorphism(self, image_point):
c(t) = c(0) + \int_0^t q(s) |q(s)|ds

with:

- c the curve that can be retrieved only up to a translation,
- q the srv representation of the curve,
- c(0) the starting point of the curve.
Expand Down Expand Up @@ -376,7 +377,7 @@ def inverse_diffeomorphism(self, image_point):
def tangent_diffeomorphism(self, tangent_vec, base_point=None, image_point=None):
r"""Differential of the square root velocity transform.

..math::
.. math::
(h, c) -> dQ_c(h) = |c'|^(-1/2} * (h' - 1/2 * <h',v>v)
v = c'/|c'|

Expand Down Expand Up @@ -431,7 +432,7 @@ def inverse_tangent_diffeomorphism(
r"""Inverse of differential of the square root velocity transform.

.. math::
(c, k) -> h, where dQ_c(h)=k and h' = |c'| * (k + <k,v> v)
(c, k) -> h, \text{ where } dQ_c(h)=k \text{ and } h' = |c'| * (k + <k,v> v)

Parameters
----------
Expand Down Expand Up @@ -521,9 +522,11 @@ class FTransform(AutodiffDiffeo):
f_transform is a bijection if and only if a/2b=1.

If a/2b is an integer not equal to 1:

- then f_transform is well-defined but many-to-one.

If a/2b is not an integer:

- then f_transform is multivalued,
- and f_transform takes finitely many values if and only if a 2b is rational.
"""
Expand Down Expand Up @@ -702,9 +705,11 @@ def riemann_sum(func):
Compute the left Riemann sum approximation of the integral of a
function func defined on the unit interval, given by sample points
at regularly spaced times
..math::

.. math::
t_i = i / (k_landmarks),
i = 0, ..., k_landmarks - 1

(last time is missing).

Parameters
Expand Down Expand Up @@ -801,8 +806,10 @@ class SRVTranslationMetric(PullbackDiffeoMetric):
"""Square Root Velocity metric on the space of discrete curves.

The SRV metric is equivalent to the elastic metric chosen with

- bending parameter a = 1,
- stretching parameter b = 1/2.

It can be obtained as the pullback of the L2 metric by the Square Root
Velocity Function.

Expand Down Expand Up @@ -1168,11 +1175,12 @@ class DynamicProgrammingAligner:
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

.. math::
end_srv@\gamma(t) = end_srv(\gamma(t))\cdot|\gamma(t)|^\frac{1}{2}
end_srv@\gamma(t) = end_srv(\gamma(t))\cdot|\gamma(t)|^\frac{1}{2}

The dynamic programming algorithm assumes that for every subinterval
:math: '\left[\frac{i}{n},\frac{i+1}{n}\right]' of :math: '\left[0,1\right]',
:math:`\left[\frac{i}{n},\frac{i+1}{n}\right]` of :math:`\left[0,1\right]`,
gamma is linear.

Parameters
Expand Down Expand Up @@ -1221,10 +1229,12 @@ def _compute_integral_restricted(srv_1, srv_2, x_min, x_max, y_min, y_max):
r"""Compute the value of an integral over a subinterval.

Compute n * the value of the integral of

.. math::
srv_1(t)\cdotsrv_2(\gamma(t))\cdot|\gamma(t)|^\frac{1}{2}
over :math: '\left[\x_min,x_max\right]' where gamma restricted to
:math: '\left[\x_min,x_max\right]' is a linear.

over :math:`\left[\x_min,x_max\right]` where gamma restricted to
:math:`\left[\x_min,x_max\right]` is a linear.

Parameters
----------
Expand Down
36 changes: 19 additions & 17 deletions geomstats/geometry/discrete_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
class DiscreteSurfaces(Manifold):
r"""Space of parameterized discrete surfaces.

Each surface is sampled with fixed n_vertices vertices and n_faces faces
in $\mathbb{R}^3$.
Each surface is sampled with fixed `n_vertices` vertices and `n_faces`
faces in :math:`\mathbb{R}^3`.

Each individual surface is represented by a 2d-array of shape `[
n_vertices, 3]`. This space corresponds to the space of immersions
Each individual surface is represented by a 2d-array of shape
`[n_vertices, 3]`. This space corresponds to the space of immersions
defined below, i.e. the
space of smooth functions from a template to manifold $M$ into $\mathbb{R}^3$,
with non-vanishing Jacobian.
space of smooth functions from a template to manifold :math:`M`
into :math:`\mathbb{R}^3`, with non-vanishing Jacobian.

.. math::
Imm(M,\mathbb{R}^3)=\{ f \in C^{\infty}(M, \mathbb{R}^3)
\|Df(x)\|\neq 0 \forall x \in M \}.
Expand Down Expand Up @@ -366,8 +367,8 @@ def laplacian(self, point):
r"""Compute the mesh Laplacian operator of a triangulated surface.

Denoting q the surface, i.e. the point in the DiscreteSurfaces manifold,
the laplacian at q is defined as the operator:
:math: `\Delta_q = - Tr(g_q^{-1} \nabla^2)`
the laplacian at :math:`q` is defined as the operator:
:math:`\Delta_q = - Tr(g_q^{-1} \nabla^2)`
where :math:`g_q` is the surface metric matrix of :math:`q`.

Parameters
Expand Down Expand Up @@ -467,8 +468,8 @@ def _laplacian(tangent_vec):
class ElasticMetric(RiemannianMetric):
"""Elastic metric defined by a family of second order Sobolev metrics.

Each individual discrete surface is represented by a 2D-array of shape `[
n_vertices, 3]`. See [HSKCB2022]_ for details.
Each individual discrete surface is represented by a 2D-array of shape
`[n_vertices, 3]`. See [HSKCB2022]_ for details.

The parameters a0, a1, b1, c1, d1, a2 (detailed below) are non-negative weighting
coefficients for the different terms in the metric.
Expand Down Expand Up @@ -525,7 +526,7 @@ def _inner_product_a0(self, tangent_vec_a, tangent_vec_b, vertex_areas_bp):
:math:`\int_M (G_{a_0} + G_{a_1} + G_{b_1} + G_{c_1} + G_{d_1} + G_{a_2})vol_q`.

This method computes :math:`G_{a_0} = a_0 <h, k>`,
with notations taken from .. [HSKCB2022].
with notations taken from [HSKCB2022]_.

Parameters
----------
Expand Down Expand Up @@ -563,7 +564,7 @@ def _inner_product_a1(self, ginvdga, ginvdgb, areas_bp):
:math:`\int_M (G_{a_0} + G_{a_1} + G_{b_1} + G_{c_1} + G_{d_1} + G_{a_2})vol_q`.

This method computes :math:`G_{a_1} = a_1.g_q^{-1} <dh_m, dk_m>`,
with notations taken from .. [HSKCB2022].
with notations taken from [HSKCB2022]_.

Parameters
----------
Expand Down Expand Up @@ -602,7 +603,7 @@ def _inner_product_b1(self, ginvdga, ginvdgb, areas_bp):
:math:`\int_M (G_{a_0} + G_{a_1} + G_{b_1} + G_{c_1} + G_{d_1} + G_{a_2})vol_q`.

This method computes :math:`G_{b_1} = b_1.g_q^{-1} <dh_+, dk_+>`,
with notations taken from .. [HSKCB2022].
with notations taken from [HSKCB2022]_.

Parameters
----------
Expand Down Expand Up @@ -643,7 +644,7 @@ def _inner_product_c1(self, point_a, point_b, normals_bp, areas_bp):
:math:`\int_M (G_{a_0} + G_{a_1} + G_{b_1} + G_{c_1} + G_{d_1} + G_{a_2})vol_q`.

This method computes :math:`G_{c_1} = c_1.g_q^{-1} <dh_\perp, dk_\perp>`,
with notations taken from .. [HSKCB2022].
with notations taken from [HSKCB2022]_.

Parameters
----------
Expand Down Expand Up @@ -685,7 +686,7 @@ def _inner_product_d1(
:math:`\int_M (G_{a_0} + G_{a_1} + G_{b_1} + G_{c_1} + G_{d_1} + G_{a_2})vol_q`.

This method computes :math:`G_{d_1} = d_1.g_q^{-1} <dh_0, dk_0>`,
with notations taken from .. [HSKCB2022].
with notations taken from [HSKCB2022]_.

Parameters
----------
Expand Down Expand Up @@ -755,7 +756,7 @@ def _inner_product_a2(
:math:`\int_M (G_{a_0} + G_{a_1} + G_{b_1} + G_{c_1} + G_{d_1} + G_{a_2})vol_q`.

This method computes :math:`G_{a_2} = a_2 <\Delta_q h, \Delta_q k>`,
with notations taken from .. [HSKCB2022].
with notations taken from [HSKCB2022]_.

Parameters
----------
Expand Down Expand Up @@ -803,14 +804,15 @@ def inner_product(self, tangent_vec_a, tangent_vec_b, base_point):
:math:`\int_M (G_{a_0} + G_{a_1} + G_{b_1} + G_{c_1} + G_{d_1} + G_{a_2})vol_q`

where:

- :math:`G_{a_0} = a_0 <h, k>`
- :math:`G_{a_1} = a_1.g_q^{-1} <dh_m, dk_m>`
- :math:`G_{b_1} = b_1.g_q^{-1} <dh_+, dk_+>`
- :math:`G_{c_1} = c_1.g_q^{-1} <dh_\perp, dk_\perp>`
- :math:`G_{d_1} = d_1.g_q^{-1} <dh_0, dk_0>`
- :math:`G_{a_2} = a_2 <\Delta_q h, \Delta_q k>`

with notations taken from .. [HSKCB2022].
with notations taken from [HSKCB2022]_.

Parameters
----------
Expand Down
14 changes: 7 additions & 7 deletions geomstats/geometry/fiber_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def integrability_tensor(self, tangent_vec_a, tangent_vec_b, base_point):

The fundamental integrability tensor A is defined for tangent vectors
:math:`X = tangent\_vec\_a` and :math:`Y = tangent\_vec\_b` of the
total space by [O'Neill]_ as
total space by [ONeill]_ as
:math:`A_X Y = ver\nabla_{hor X} (hor Y) + hor \nabla_{hor X}( ver Y)`
where :math:`hor, ver` are the horizontal and vertical projections
and :math:`\nabla` is the connection of the total space.
Expand All @@ -366,7 +366,7 @@ def integrability_tensor(self, tangent_vec_a, tangent_vec_b, base_point):

References
----------
.. [O'Neill] O’Neill, Barrett. The Fundamental Equations of a
.. [ONeill] O’Neill, Barrett. The Fundamental Equations of a
Submersion, Michigan Mathematical Journal 13, no. 4
(December 1966): 459–69. https://doi.org/10.1307/mmj/1028999604.
"""
Expand All @@ -388,12 +388,12 @@ def integrability_tensor_derivative(
curvature in a submersion. The components :math:`\nabla_X (A_Y E)`
and :math:`A_Y E` are computed at base-point :math:`P = base\_point`
for horizontal vector fields :math:`X, Y` extending the values
given in argument :math:`X|_P = horizontal_vec_x`,
given in argument :math:`X|_P = horizontal\_vec\_x`,
:math:`Y|_P = horizontal\_vec\_y` and a general vector field
:math:`E` extending :math:`E|_x =
tangent\_vec\_e` in a neighborhood of x with covariant derivatives
:math:`\nabla_X Y |_P = nabla_x_y` and
:math:`\nabla_X E |_P = nabla_x_e`.
:math:`E` extending :math:`E|_x = tangent\_vec\_e`
in a neighborhood of x with covariant derivatives
:math:`\nabla_X Y |_P = nabla_x y` and
:math:`\nabla_X E |_P = nabla_x e`.

Parameters
----------
Expand Down
4 changes: 2 additions & 2 deletions geomstats/geometry/full_rank_correlation_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def diag_action(diagonal_vec, point):
r"""Apply a diagonal matrix on an SPD matrices by congruence.

The action of :math:`D` on :math:`\Sigma` is given by :math:`D
\Sigma D. The diagonal matrix must be passed as a vector representing
\Sigma D`. The diagonal matrix must be passed as a vector representing
its diagonal.

Parameters
Expand All @@ -109,7 +109,7 @@ def from_covariance(cls, point):
r"""Compute the correlation matrix associated to an SPD matrix.

The correlation matrix associated to an SPD matrix (the covariance)
:math:`\Sigma` is given by :math:`D \Sigma D` where :math:`D` is
:math:`\Sigma` is given by :math:`D \Sigma D` where :math:`D` is
the inverse square-root of the diagonal of :math:`\Sigma`.

Parameters
Expand Down
Loading