Skip to contents

An R6::R6Class object implementing the base Manifold class. In other words, a topological space that locally resembles Euclidean space near each point.

Author

Nina Miolane

Super class

rgeomstats::PythonClass -> Manifold

Public fields

dim

An integer value specifying the dimension of the manifold.

shape

An integer vector specifying the shape of one element of the manifold. Defaults to NULL.

metric

A RiemannianMetric object specifying the metric to use on the manifold. Defaults to NULL.

default_coords_type

A string specifying the coordinate type. Choices are extrensic or intrinsic. Dedaults to intrinsic.

default_point_type

A string specifying the point type. Choices are vector or matrix. It is automatically determined depending on the manifold.

Methods

Inherited methods


Method new()

The Manifold class constructor.

Usage

Manifold$new(
  dim,
  shape = NULL,
  metric = NULL,
  default_coords_type = "intrinsic",
  py_cls = NULL
)

Arguments

dim

An integer value specifying the dimension of the manifold.

shape

An integer vector specifying the shape of one element of the manifold. Defaults to NULL.

metric

A RiemannianMetric object specifying the metric to use on the manifold. Defaults to NULL.

default_coords_type

A string specifying the coordinate type. Choices are extrinsic or intrinsic. Defaults to intrinsic.

py_cls

A Python object of class Manifold. Defaults to NULL in which case it is instantiated on the fly using the other input arguments.

Returns

An object of class Manifold.


Method belongs()

Evaluates if a point belongs to the manifold.

Usage

Manifold$belongs(point, atol = gs$backend$atol)

Arguments

point

A numeric array of shape \([\dots \times \{\mathrm{dim}\}]\) specifying one or more points to be checked.

atol

A numeric value specifying the absolute tolerance for checking. Defaults to gs$backend$atol.

Returns

A boolean value or vector storing whether the corresponding points belong to the manifold.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  A <- diag(1, 3)
  spd3$belongs(diag(1, 3))
}


Method is_tangent()

Checks whether a vector is tangent at a base point.

Usage

Manifold$is_tangent(vector, base_point = NULL, atol = gs$backend$atol)

Arguments

vector

A numeric array of shape \([\dots \times [\mathrm{dim}]]\) specifying one or more vectors to be checked.

base_point

A numeric array of shape \([\dots \times [\mathrm{dim}]]\) specifying one or more base points on the manifold. Defaults to NULL in which case the identity is used.

atol

A numeric value specifying the absolute tolerance for checking. Defaults to gs$backend$atol.

Returns

A boolean value or vector storing whether the corresponding points are tangent to the manifold at corresponding base points.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  A <- diag(1, 3)
  spd3$is_tangent(diag(1, 3))
}


Method to_tangent()

Projects a vector to a tangent space of the manifold.

Usage

Manifold$to_tangent(vector, base_point = NULL)

Arguments

vector

A numeric array of shape \([\dots \times [\mathrm{dim}]]\) specifying one or more vectors to project on the manifold.

base_point

A numeric array of shape \([\dots \times [\mathrm{dim}]]\) specifying one or more base points on the manifold. Defaults to NULL in which case the identity is used.

Returns

A numeric array of shape \([\dots \times \{\mathrm{dim}\}]\) storing the corresponding projections onto the manifold at corresponding base points.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  A <- diag(1, 3)
  spd3$to_tangent(diag(1, 3))
}


Method random_point()

Samples random points on the manifold.

Usage

Manifold$random_point(n_samples = 1, bound = 1)

Arguments

n_samples

An integer value specifying the number of samples to be drawn. Defaults to 1L.

bound

A numeric value specifying the bound of the interval in which to sample for non-compact manifolds. Defaults to 1L.

Details

If the manifold is compact, a uniform distribution is used.

Returns

A numeric array of shape \([\dots \times \{\mathrm{dim}\}]\) storing a sample of points on the manifold.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  # spd3$random_point(10) # TO DO: uncomment when bug fixed in gs
}


Method regularize()

Regularizes a point to the canonical representation for the manifold.

Usage

Manifold$regularize(point)

Arguments

point

A numeric array of shape \([\dots \times [\mathrm{dim}]]\) specifying one or more points on the manifold.

Returns

A numeric array of the same shape storing the corresponding regularized points.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  A <- diag(1, 3)
  spd3$regularize(diag(1, 3))
}


Method set_metric()

Sets the Riemannian Metric associated to the manifold.

Usage

Manifold$set_metric(metric)

Arguments

metric

An object of class RiemannianMetric.

Returns

The Manifold class itself invisibly.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  spd3$metric
  spd3$set_metric(SPDMetricBuresWasserstein$new(n = 3))
  spd3$metric
}


Method random_tangent_vec()

Generates a random tangent vector.

Usage

Manifold$random_tangent_vec(base_point, n_samples = 1)

Arguments

base_point

A numeric array of shape \([\dots \times \{\mathrm{dim}\}]\) specifying one or more base points on the manifold.

n_samples

An integer value specifying the number of samples to be drawn. Defaults to 1L.

Returns

A numeric array of shape \([\dots \times \{\mathrm{dim}\}]\) storing a sample of vectors that are tangent to the manifold at corresponding base points.

Examples

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  spd3$random_tangent_vec(diag(1, 3), 10)
}


Method clone()

The objects of this class are cloneable with this method.

Usage

Manifold$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `Manifold$belongs`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  A <- diag(1, 3)
  spd3$belongs(diag(1, 3))
}

## ------------------------------------------------
## Method `Manifold$is_tangent`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  A <- diag(1, 3)
  spd3$is_tangent(diag(1, 3))
}

## ------------------------------------------------
## Method `Manifold$to_tangent`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  A <- diag(1, 3)
  spd3$to_tangent(diag(1, 3))
}

## ------------------------------------------------
## Method `Manifold$random_point`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  # spd3$random_point(10) # TO DO: uncomment when bug fixed in gs
}

## ------------------------------------------------
## Method `Manifold$regularize`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  A <- diag(1, 3)
  spd3$regularize(diag(1, 3))
}

## ------------------------------------------------
## Method `Manifold$set_metric`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  spd3$metric
  spd3$set_metric(SPDMetricBuresWasserstein$new(n = 3))
  spd3$metric
}

## ------------------------------------------------
## Method `Manifold$random_tangent_vec`
## ------------------------------------------------

if (reticulate::py_module_available("geomstats")) {
  spd3 <- SPDMatrix(n = 3)
  spd3$random_tangent_vec(diag(1, 3), 10)
}