An R6::R6Class object implementing the base Manifold
class. In other words, a topological space that locally resembles Euclidean
space near each point.
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
orintrinsic
. Dedaults tointrinsic
.default_point_type
A string specifying the point type. Choices are
vector
ormatrix
. It is automatically determined depending on the manifold.
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 toNULL
.default_coords_type
A string specifying the coordinate type. Choices are
extrinsic
orintrinsic
. Defaults tointrinsic
.py_cls
A Python object of class
Manifold
. Defaults toNULL
in which case it is instantiated on the fly using the other input arguments.
Method belongs()
Evaluates if a point belongs to the manifold.
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
.
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.
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.
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.
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
.
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.
Arguments
point
A numeric array of shape \([\dots \times [\mathrm{dim}]]\) specifying one or more points on the manifold.
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.
Arguments
metric
An object of class
RiemannianMetric
.
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.
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)
}
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)
}