nlgm.manifolds Module#

class nlgm.manifolds.BasicManifold(dimension: int, curvature: float, base_point: Tensor = None)[source]#

Base manifold class with shared geometry attributes.

Parameters:
dimensionint

Dimension of the manifold.

curvaturefloat

Scalar curvature of the manifold.

base_pointtorch.Tensor, optional

Origin point of the tangent space. If omitted, a zero vector of length dimension is used.

Methods

distance(point_x, point_y)

Compute geodesic distance between two points on the manifold.

exponential_map(tangent_vector)

Map a tangent-space vector onto the manifold.

distance(point_x: Tensor, point_y: Tensor) Tensor[source]#

Compute geodesic distance between two points on the manifold.

Parameters:
point_xtorch.Tensor

First point.

point_ytorch.Tensor

Second point.

Returns:
torch.Tensor

Geodesic distance between point_x and point_y.

exponential_map(tangent_vector: Tensor) Tensor[source]#

Map a tangent-space vector onto the manifold.

Parameters:
tangent_vectortorch.Tensor

Tangent vector to map.

Returns:
torch.Tensor

Mapped point on the manifold.

class nlgm.manifolds.EuclideanManifold(dimension: int, curvature: float, base_point: Tensor = None)[source]#

Methods

distance(point_x, point_y)

Compute Euclidean distance between two points.

exponential_map(tangent_vector)

Map a tangent vector in Euclidean space.

distance(point_x: Tensor, point_y: Tensor) Tensor[source]#

Compute Euclidean distance between two points.

Parameters:
point_xtorch.Tensor

First point.

point_ytorch.Tensor

Second point.

Returns:
torch.Tensor

Euclidean distance between point_x and point_y.

exponential_map(tangent_vector: Tensor) Tensor[source]#

Map a tangent vector in Euclidean space.

Parameters:
tangent_vectortorch.Tensor

Tangent vector to map.

Returns:
torch.Tensor

The mapped point, equal to tangent_vector in Euclidean space.

class nlgm.manifolds.HyperbolicManifold(dimension: int, curvature: float, base_point: Tensor = None)[source]#

Methods

distance(point_x, point_y)

Compute hyperbolic geodesic distance between two points.

exponential_map(tangent_vector)

Map a tangent vector onto a hyperbolic manifold.

distance(point_x: Tensor, point_y: Tensor) Tensor[source]#

Compute hyperbolic geodesic distance between two points.

Parameters:
point_xtorch.Tensor

First point.

point_ytorch.Tensor

Second point.

Returns:
torch.Tensor

Geodesic distance between point_x and point_y.

exponential_map(tangent_vector: Tensor) Tensor[source]#

Map a tangent vector onto a hyperbolic manifold.

Parameters:
tangent_vectortorch.Tensor

Tangent vector to map.

Returns:
torch.Tensor

Point on the hyperbolic manifold after exponential mapping.

class nlgm.manifolds.ProductManifold(curvatures: List[float])[source]#

Product manifold assembled from fixed-size component manifolds.

Parameters:
curvatureslist[float]

Curvatures for each component manifold.

Methods

distance(point_x, point_y)

Compute product-manifold distance between two points.

exponential_map(latent_vector)

Apply per-component exponential maps and concatenate the result.

Notes

Each component manifold is assumed to have dimension 2.

distance(point_x: Tensor, point_y: Tensor) Tensor[source]#

Compute product-manifold distance between two points.

Parameters:
point_xtorch.Tensor

First point in product-manifold coordinates.

point_ytorch.Tensor

Second point in product-manifold coordinates.

Returns:
torch.Tensor

Distance between point_x and point_y.

exponential_map(latent_vector: Tensor) Tensor[source]#

Apply per-component exponential maps and concatenate the result.

Parameters:
latent_vectortorch.Tensor

Latent vector in Euclidean space. Its last dimension should match the sum of component manifold dimensions.

Returns:
torch.Tensor

Projection of latent_vector into the product manifold space.

class nlgm.manifolds.SphericalManifold(dimension: int, curvature: float, base_point: Tensor = None)[source]#

Methods

distance(point_x, point_y)

Compute spherical geodesic distance between two points.

exponential_map(tangent_vector)

Map a tangent vector onto a spherical manifold.

distance(point_x: Tensor, point_y: Tensor) Tensor[source]#

Compute spherical geodesic distance between two points.

Parameters:
point_xtorch.Tensor

First point.

point_ytorch.Tensor

Second point.

Returns:
torch.Tensor

Geodesic distance between point_x and point_y.

exponential_map(tangent_vector: Tensor) Tensor[source]#

Map a tangent vector onto a spherical manifold.

Parameters:
tangent_vectortorch.Tensor

Tangent vector to map.

Returns:
torch.Tensor

Point on the spherical manifold after exponential mapping.