ManifoldsBase.jl – an interface for manifolds

The interface for a manifold is provided in the lightweight package ManifoldsBase.jl. You can easily implement your algorithms and even your own manifolds just using the interface. All manifolds from the package here are also based on this interface, so any project based on the interface can benefit from all manifolds, as soon as a certain manifold provides implementations of the functions a project requires.

Additionally the AbstractDecoratorManifold is provided as well as the ValidationManifold as a specific example of such a decorator.

Types and functions

The following functions are currently available from the interface. If a manifold that you implement for your own package fits this interface, we happily look forward to a Pull Request to add it here.

ManifoldsBase.CoTVectorType
CoTVector

Type for a cotangent vector of a manifold. While a Manifold does not necessarily require this type, for example when it is implemented for Vectors or Matrix type elements, this type can be used for more complicated representations, semantic verification, or even dispatch for different representations of cotangent vectors and their types on a manifold.

ManifoldsBase.MPointType
MPoint

Type for a point on a manifold. While a Manifold does not necessarily require this type, for example when it is implemented for Vectors or Matrix type elements, this type can be used for more complicated representations, semantic verification, or even dispatch for different representations of points on a manifold.

ManifoldsBase.ManifoldType
Manifold{F}

A manifold type. The Manifold is used to dispatch to different functions on a manifold, usually as the first argument of the function. Examples are the exponential and logarithmic maps as well as more general functions that are built on them like the geodesic.

The manifold is parametrized by an AbstractNumbers to distinguish for example real (ℝ) and complex (ℂ) manifolds.

For subtypes the preferred order of parameters is: size and simple value parameters, followed by the AbstractNumbers field, followed by data type parameters, which might depend on the abstract number field type.

ManifoldsBase.PolarInverseRetractionType
PolarInverseRetraction <: AbstractInverseRetractionMethod

Inverse retractions that are based on a singular value decomposition of the matrix / matrices for point and tangent vector on a Manifold

ManifoldsBase.PolarRetractionType
PolarRetraction <: AbstractRetractionMethod

Retractions that are based on singular value decompositions of the matrix / matrices for point and tangent vector on a Manifold

ManifoldsBase.ProjectionRetractionType
ProjectionRetraction <: AbstractRetractionMethod

Retractions that are based on projection and usually addition in the embedding.

ManifoldsBase.QRInverseRetractionType
QRInverseRetraction <: AbstractInverseRetractionMethod

Inverse retractions that are based on a QR decomposition of the matrix / matrices for point and tangent vector on a Manifold

ManifoldsBase.QRRetractionType
QRRetraction <: AbstractRetractionMethod

Retractions that are based on a QR decomposition of the matrix / matrices for point and tangent vector on a Manifold

ManifoldsBase.TVectorType
TVector

Type for a tangent vector of a manifold. While a Manifold does not necessarily require this type, for example when it is implemented for Vectors or Matrix type elements, this type can be used for more complicated representations, semantic verification, or even dispatch for different representations of tangent vectors and their types on a manifold.

Base.expMethod
exp(M::Manifold, p, X)
exp(M::Manifold, p, X, t::Real = 1)

Compute the exponential map of tangent vector X, optionally scaled by t, at point p from manifold the Manifold M.

Base.isapproxMethod
isapprox(M::Manifold, p, X, Y; kwargs...)

Check if vectors X and Y tangent at p from Manifold M are approximately equal.

Keyword arguments can be used to specify tolerances.

Base.isapproxMethod
isapprox(M::Manifold, p, q; kwargs...)

Check if points p and q from Manifold M are approximately equal.

Keyword arguments can be used to specify tolerances.

Base.logMethod
log(M::Manifold, p, q)

Compute the logarithmic map of point q at base point p on the Manifold M.

LinearAlgebra.normMethod
norm(M::Manifold, p, X)

Compute the norm of tangent vector X at point p from a Manifold M. By default this is computed using inner.

ManifoldsBase.allocateMethod
allocate(a)
allocate(a, dims::Integer...)
allocate(a, dims::Tuple)
allocate(a, T::Type)
allocate(a, T::Type, dims::Integer...)
allocate(a, T::Type, dims::Tuple)

Allocate an object similar to a. It is similar to function similar, although instead of working only on the outermost layer of a nested structure, it maps recursively through outer layers and calls similar on the innermost array-like object only. Type T is the new number element type number_eltype, if it is not given the element type of a is retained. The dims argument can be given for non-nested allocation and is forwarded to the function similar.

ManifoldsBase.base_manifoldFunction
base_manifold(M::Manifold, depth = Val(-1))

Return the internally stored Manifold for decorated manifold M and the base manifold for vector bundles or power manifolds. The optional parameter depth can be used to remove only the first depth many decorators and return the Manifold from that level, whether its decorated or not. Any negative value deactivates this depth limit.

ManifoldsBase.check_manifold_pointMethod
check_manifold_point(M::Manifold, p; kwargs...) -> Union{Nothing,String}

Return nothing when p is a point on the Manifold M. Otherwise, return an error with description why the point does not belong to manifold M.

By default, check_manifold_point returns nothing, i.e. if no checks are implemented, the assumption is to be optimistic for a point not deriving from the MPoint type.

ManifoldsBase.check_tangent_vectorMethod
check_tangent_vector(M::Manifold, p, X; kwargs...) -> Union{Nothing,String}

Check whether X is a valid tangent vector in the tangent space of p on the Manifold M. An implementation should first call check_manifold_point(M, p; kwargs...) and then validate X. If it is not a tangent vector, an error string should be returned.

By default, check_tangent_vector returns nothing, i.e. if no checks are implemented, the assumption is to be optimistic for tangent vectors not deriving from the TVector type.

ManifoldsBase.embed!Method
embed!(M::Manifold, Y, p, X)

Embed a tangent vector X at a point p on the Manifold M into the ambient space and return the result in Y. This method is only available for manifolds where implicitly an embedding or ambient space is given. Additionally, embed! includes changing data representation, if applicable, i.e. if the tangents on M are not represented in the same way as tangents on the embedding, the representation is changed accordingly. This is the case for example for Lie groups, when tangent vectors are represented in the Lie algebra. The embedded tangents are then in the tangent spaces of the embedded base points.

See also: EmbeddedManifold, project!

ManifoldsBase.embed!Method
embed!(M::Manifold, q, p)

Embed point p from the Manifold M into the ambient space and return the result in q. This method is only available for manifolds where implicitly an embedding or ambient space is given. Additionally, embed includes changing data representation, if applicable, i.e. if the points on M are not represented in the same way as points on the embedding, the representation is changed accordingly.

See also: EmbeddedManifold, project!

ManifoldsBase.embedMethod
embed(M::Manifold, p, X)

Embed a tangent vector X at a point p on the Manifold M into the ambient space. This method is only available for manifolds where implicitly an embedding or ambient space is given. Additionally, embed includes changing data representation, if applicable, i.e. if the tangents on M are not represented in the same way as tangents on the embedding, the representation is changed accordingly. This is the case for example for Lie groups, when tangent vectors are represented in the Lie algebra. The embedded tangents are then in the tangent spaces of the embedded base points.

See also: EmbeddedManifold, project

ManifoldsBase.embedMethod
embed(M::Manifold, p)

Embed point p from the Manifold M into the ambient space. This method is only available for manifolds where implicitly an embedding or ambient space is given. Additionally, embed includes changing data representation, if applicable, i.e. if the points on M are not represented in the same way as points on the embedding, the representation is changed accordingly.

See also: EmbeddedManifold, project

ManifoldsBase.exp!Method
exp!(M::Manifold, q, p, X)
exp!(M::Manifold, q, p, X, t::Real = 1)

Compute the exponential map of tangent vector X, optionally scaled by t, at point p from manifold the Manifold M. The result is saved to q.

ManifoldsBase.geodesicMethod
geodesic(M::Manifold, p, X) -> Function

Get the geodesic with initial point p and velocity X on the Manifold M. The geodesic is the curve of constant velocity that is locally distance-minimizing. This function returns a function of (time) t.

geodesic(M::Manifold, x, v, t::Real)
geodesic(M::Manifold, x, v, T::AbstractVector) -> AbstractVector

Return the point at time t or points at times t in T along the geodesic.

ManifoldsBase.injectivity_radiusMethod
injectivity_radius(M::Manifold, p)

Return the distance $d$ such that exp(M, p, X) is injective for all tangent vectors shorter than $d$ (i.e. has an inverse).

injectivity_radius(M::Manifold)

Infimum of the injectivity radius of all manifold points.

injectivity_radius(M::Manifold[, x], method::AbstractRetractionMethod)
injectivity_radius(M::Manifold, x, method::AbstractRetractionMethod)

Distance $d$ such that retract(M, p, X, method) is injective for all tangent vectors shorter than $d$ (i.e. has an inverse) for point p if provided or all manifold points otherwise.

ManifoldsBase.inverse_retract!Method
inverse_retract!(M::Manifold, X, p, q[, method::AbstractInverseRetractionMethod])

Compute the inverse retraction, a cheaper, approximate version of the logarithmic map), of points p and q on the Manifold M. Result is saved to X.

Inverse retraction method can be specified by the last argument, defaulting to LogarithmicInverseRetraction. See the documentation of respective manifolds for available methods.

ManifoldsBase.inverse_retractMethod
inverse_retract(M::Manifold, x, y)
inverse_retract(M::Manifold, x, y, method::AbstractInverseRetractionMethod

Compute the inverse retraction, a cheaper, approximate version of the logarithmic map), of points p and q on the Manifold M.

Inverse retraction method can be specified by the last argument, defaulting to LogarithmicInverseRetraction. See the documentation of respective manifolds for available methods.

ManifoldsBase.is_manifold_pointFunction
is_manifold_point(M::Manifold, p, throw_error = false; kwargs...)

Return whether p is a valid point on the Manifold M.

If throw_error is false, the function returns either true or false. If throw_error is true, the function either returns true or throws an error. By default the function calls check_manifold_point(M, p; kwargs...) and checks whether the returned value is nothing or an error.

ManifoldsBase.is_tangent_vectorFunction
is_tangent_vector(M::Manifold, p, X, throw_error = false; kwargs...)

Return whether X is a valid tangent vector at point p on the Manifold M. Returns either true or false.

If throw_error is false, the function returns either true or false. If throw_error is true, the function either returns true or throws an error. By default the function calls check_tangent_vector(M, p, X; kwargs...) and checks whether the returned value is nothing or an error.

ManifoldsBase.log!Method
log!(M::Manifold, X, p, q)

Compute the logarithmic map of point q at base point p on the Manifold M. The result is saved to X.

ManifoldsBase.manifold_dimensionMethod
manifold_dimension(M::Manifold)

The dimension $n=\dim_{\mathcal M}$ of real space $\mathbb R^n$ to which the neighborhood of each point of the Manifold M is homeomorphic.

ManifoldsBase.project!Method
project!(M::Manifold, Y, p, X)

Project ambient space representation of a vector X to a tangent vector at point p on the Manifold M. The result is saved in vector Y. This method is only available for manifolds where implicitly an embedding or ambient space is given. Additionally, project! includes changing data representation, if applicable, i.e. if the tangents on M are not represented in the same way as points on the embedding, the representation is changed accordingly. This is the case for example for Lie groups, when tangent vectors are represented in the Lie algebra. after projection the change to the Lie algebra is perfomed, too.

See also: EmbeddedManifold, embed!

ManifoldsBase.project!Method
project!(M::Manifold, q, p)

Project point p from the ambient space onto the Manifold M. The result is storedin q. This method is only available for manifolds where implicitly an embedding or ambient space is given. Additionally, the projection includes changing data representation, if applicable, i.e. if the points on M are not represented in the same array data, the data is changed accordingly.

See also: EmbeddedManifold, embed!

ManifoldsBase.projectMethod
project(M::Manifold, p, X)

Project ambient space representation of a vector X to a tangent vector at point p on the Manifold M. This method is only available for manifolds where implicitly an embedding or ambient space is given. Additionally, project includes changing data representation, if applicable, i.e. if the tangents on M are not represented in the same way as points on the embedding, the representation is changed accordingly. This is the case for example for Lie groups, when tangent vectors are represented in the Lie algebra. after projection the change to the Lie algebra is perfomed, too.

See also: EmbeddedManifold, embed

ManifoldsBase.projectMethod
project(M::Manifold, p)

Project point p from the ambient space of the Manifold M to M. This method is only available for manifolds where implicitly an embedding or ambient space is given. Additionally, the projection includes changing data representation, if applicable, i.e. if the points on M are not represented in the same array data, the data is changed accordingly.

See also: EmbeddedManifold, embed

ManifoldsBase.retract!Method
retract!(M::Manifold, q, p, X)
retract!(M::Manifold, q, p, X, t::Real=1)
retract!(M::Manifold, q, p, X, method::AbstractRetractionMethod)
retract!(M::Manifold, q, p, X, t::Real=1, method::AbstractRetractionMethod)

Compute a retraction, a cheaper, approximate version of the exponential map, from p into direction X, scaled by t, on the Manifold manifold M. Result is saved to q.

Retraction method can be specified by the last argument, defaulting to ExponentialRetraction. See the documentation of respective manifolds for available methods.

ManifoldsBase.retractMethod
retract(M::Manifold, p, X)
retract(M::Manifold, p, X, t::Real=1)
retract(M::Manifold, p, X, method::AbstractRetractionMethod)
retract(M::Manifold, p, X, t::Real=1, method::AbstractRetractionMethod)

Compute a retraction, a cheaper, approximate version of the exponential map, from p into direction X, scaled by t, on the Manifold M.

Retraction method can be specified by the last argument, defaulting to ExponentialRetraction. See the documentation of respective manifolds for available methods.

ManifoldsBase.shortest_geodesicMethod
shortest_geodesic(M::Manifold, p, q) -> Function

Get a geodesic $\gamma_{p,q}(t)$ whose length is the shortest path between the points pand q, where $\gamma_{p,q}(0)=p$ and $\gamma_{p,q}(1)=q$. When there are multiple shortest geodesics, there is no guarantee which will be returned.

This function returns a function of time, which may be a Real or an AbstractVector.

shortest_geodesic(M::Manifold, p, q, t::Real)
shortest_geodesic(M::Manifold, p, q, T::AbstractVector) -> AbstractVector

Return the point at time t or points at times t in T along the shortest geodesic.

ManifoldsBase.vector_transport_along!Method
vector_transport_along!(M::Manifold, Y, p, X, c)
vector_transport_along!(M::Manifold, Y, p, X, c, method::AbstractVectorTransportMethod)

Transport a vector X from the tangent space at a point p on the Manifold M along the curve c such that c(0) is equal to p to the point c(1) using the method, which defaults to ParallelTransport. The result is saved to Y.

ManifoldsBase.vector_transport_alongMethod
vector_transport_along(M::Manifold, p, X, c)
vector_transport_along(M::Manifold, p, X, c, method::AbstractVectorTransportMethod)

Transport a vector X from the tangent space at a point p on the Manifold M along the curve c such that c(0) is equal to p to the point c(1) using the method, which defaults to ParallelTransport.

ManifoldsBase.vector_transport_direction!Method
vector_transport_direction!(M::Manifold, Y, p, X, d)
vector_transport_direction!(M::Manifold, Y, p, X, d, method::AbstractVectorTransportMethod)

Transport a vector X from the tangent space at a point p on the Manifold M in the direction indicated by the tangent vector d at p. By default, exp and vector_transport_to! are used with the method, which defaults to ParallelTransport. The result is saved to Y.

ManifoldsBase.vector_transport_to!Method
vector_transport_to!(M::Manifold, Y, p, X, q, method::ProjectionTransport)

Transport a vector X from the tangent space at p on the Manifold M by interpreting it as an element of the embedding and then projecting it onto the tangent space at q. This method requires project.

ManifoldsBase.zero_tangent_vectorMethod
zero_tangent_vector(M::Manifold, p)

Return the tangent vector from the tangent space at p on the Manifold M, that represents the zero vector, i.e. such that a retraction at p produces p.

Base.angleMethod
angle(M::Manifold, p, X, Y)

Compute the angle between tangent vectors X and Y at point p from the Manifold M with respect to the inner product from inner.

ManifoldsBase.allocate_resultMethod
allocate_result(M::Manifold, f, x...)

Allocate an array for the result of function f on Manifold M and arguments x... for implementing the non-modifying operation using the modifying operation.

Usefulness of passing a function is demonstrated by methods that allocate results of musical isomorphisms.

ManifoldsBase.allocate_result_typeMethod
allocate_result_type(M::Manifold, f, args::NTuple{N,Any}) where N

Return type of element of the array that will represent the result of function f and the Manifold M on given arguments args (passed as a tuple).

Number systems

ManifoldsBase.number_systemMethod
number_system(M::Manifold{𝔽})

Return the number system the manifold M is based on, i.e. the parameter 𝔽.

ManifoldsBase.AbstractNumbersType
AbstractNumbers

An abstract type to represent the number system on which a manifold is built.

This provides concrete number types for dispatch. The two most common number types are the fields RealNumbers ( for short) and ComplexNumbers ().

ManifoldsBase._unify_number_systemsMethod
_unify_number_systems(𝔽s::AbstractNumbers...)

Compute a number system that includes all given number systems (as sub-systems) and is closed under addition and multiplication.

Allocation

Non-mutating functions in ManifoldsBase.jl are typically implemented using mutating variants. Allocation of new points is performed using a custom mechanism that relies on the following functions:

  • allocate that allocates a new point or vector similar to the given one. This function behaves like similar for simple representations of points and vectors (for example Array{Float64}). For more complex types, such as nested representations of PowerManifold (see NestedPowerRepresentation), FVector types, checked types like ValidationMPoint and more it operates differently. While similar only concerns itself with the higher level of nested structures, allocate maps itself through all levels of nesting until a simple array of numbers is reached and then calls similar. The difference can be most easily seen in the following example:
julia> x = similar([[1.0], [2.0]])
2-element Array{Array{Float64,1},1}:
 #undef
 #undef

julia> y = Manifolds.allocate([[1.0], [2.0]])
2-element Array{Array{Float64,1},1}:
 [6.90031725726027e-310]
 [6.9003678131654e-310]

julia> x[1]
ERROR: UndefRefError: access to undefined reference
Stacktrace:
 [1] getindex(::Array{Array{Float64,1},1}, ::Int64) at ./array.jl:744
 [2] top-level scope at REPL[12]:1

julia> y[1]
1-element Array{Float64,1}:
 6.90031725726027e-310
  • allocate_result allocates a result of a particular function (for example [exp], [flat], etc.) on a particular manifold with particular arguments. It takes into account the possibility that different arguments may have different numeric number_eltype types thorough the ManifoldsBase.allocate_result_type function.

Bases

The following functions and types provide support for bases of the tangent space of different manifolds. An orthonormal basis of the tangent space $T_p \mathcal M$ of (real) dimension $n$ has a real-coefficient basis $e_1, e_2, …, e_n$ if $\mathrm{Re}(g_p(e_i, e_j)) = δ_{ij}$ for each $i,j ∈ \{1, 2, …, n\}$ where $g_p$ is the Riemannian metric at point $p$. A vector $X$ from the tangent space $T_p \mathcal M$ can be expressed in Einstein notation as a sum $X = X^i e_i$, where (real) coefficients $X^i$ are calculated as $X^i = \mathrm{Re}(g_p(X, e_i))$.

The main types are:

The main functions are:

  • get_basis precomputes a basis at a certain point.
  • get_coordinates returns coordinates of a tangent vector.
  • get_vector returns a vector for the specified coordinates.
  • get_vectors returns a vector of basis vectors. Calling it should be avoided for high-dimensional manifolds.
ManifoldsBase.CachedBasisType
CachedBasis{𝔽,V,<:AbstractBasis{𝔽}} <: AbstractBasis{𝔽}

A cached version of the given basis with precomputed basis vectors. The basis vectors are stored in data, either explicitly (like in cached variants of ProjectedOrthonormalBasis) or implicitly.

Constructor

CachedBasis(basis::AbstractBasis, data)
ManifoldsBase.DefaultBasisType
DefaultBasis{𝔽}

An arbitrary basis on a manifold. This will usually be the fastest basis available for a manifold.

The type parameter 𝔽 denotes the AbstractNumbers that will be used for the vectors elements

ManifoldsBase.DefaultOrthogonalBasisType
DefaultOrthogonalBasis{𝔽}

An arbitrary orthogonal basis on a manifold. This will usually be the fastest orthogonal basis available for a manifold.

The type parameter 𝔽 denotes the AbstractNumbers that will be used for the vectors elements.

ManifoldsBase.DefaultOrthonormalBasisType
DefaultOrthonormalBasis(𝔽::AbstractNumbers = ℝ)

An arbitrary orthonormal basis on a manifold. This will usually be the fastest orthonormal basis available for a manifold.

The type parameter 𝔽 denotes the AbstractNumbers that will be used for the vectors elements.

ManifoldsBase.DiagonalizingOrthonormalBasisType
DiagonalizingOrthonormalBasis{𝔽,TV} <: AbstractOrthonormalBasis{𝔽}

An orthonormal basis Ξ as a vector of tangent vectors (of length determined by manifold_dimension) in the tangent space that diagonalizes the curvature tensor $R(u,v)w$ and where the direction frame_direction $v$ has curvature 0.

The type parameter 𝔽 denotes the AbstractNumbers that will be used for the vectors elements.

Constructor

DiagonalizingOrthonormalBasis(frame_direction, 𝔽::AbstractNumbers = ℝ)
ManifoldsBase.ProjectedOrthonormalBasisType
ProjectedOrthonormalBasis(method::Symbol, 𝔽::AbstractNumbers = ℝ)

An orthonormal basis that comes from orthonormalization of basis vectors of the ambient space projected onto the subspace representing the tangent space at a given point.

The type parameter 𝔽 denotes the AbstractNumbers that will be used for the vectors elements.

Available methods:

  • :gram_schmidt uses a modified Gram-Schmidt orthonormalization.
  • :svd uses SVD decomposition to orthogonalize projected vectors. The SVD-based method should be more numerically stable at the cost of an additional assumption (local metric tensor at a point where the basis is calculated has to be diagonal).
ManifoldsBase.get_basisMethod
get_basis(M::Manifold, p, B::AbstractBasis) -> CachedBasis

Compute the basis vectors of the tangent space at a point on manifold M represented by p.

Returned object derives from AbstractBasis and may have a field .vectors that stores tangent vectors or it may store them implicitly, in which case the function get_vectors needs to be used to retrieve the basis vectors.

See also: get_coordinates, get_vector

ManifoldsBase.get_coordinatesMethod
get_coordinates(M::Manifold, p, X, B::AbstractBasis)
get_coordinates(M::Manifold, p, X, B::CachedBasis)

Compute a one-dimensional vector of coefficients of the tangent vector X at point denoted by p on manifold M in basis B.

Depending on the basis, p may not directly represent a point on the manifold. For example if a basis transported along a curve is used, p may be the coordinate along the curve. If a CachedBasis is provided, their stored vectors are used, otherwise the user has to provide a method to compute the coordinates.

For the CachedBasis keep in mind that the reconstruction with get_vector requires either a dual basis or the cached basis to be selfdual, for example orthonormal

See also: get_vector, get_basis

ManifoldsBase.get_vectorMethod
get_vector(M::Manifold, p, X, B::AbstractBasis)

Convert a one-dimensional vector of coefficients in a basis B of the tangent space at p on manifold M to a tangent vector X at p.

Depending on the basis, p may not directly represent a point on the manifold. For example if a basis transported along a curve is used, p may be the coordinate along the curve.

For the CachedBasis keep in mind that the reconstruction from get_coordinates requires either a dual basis or the cached basis to be selfdual, for example orthonormal

See also: get_coordinates, get_basis

ManifoldsBase.get_vectorsMethod
get_vectors(M::Manifold, p, B::AbstractBasis)

Get the basis vectors of basis B of the tangent space at point p.

ManifoldsBase.hatMethod
hat(M::Manifold, p, Xⁱ)

Given a basis $e_i$ on the tangent space at a point p and tangent component vector $X^i$, compute the equivalent vector representation $X=X^i e_i$, where Einstein summation notation is used:

\[∧ : X^i ↦ X^i e_i\]

For array manifolds, this converts a vector representation of the tangent vector to an array representation. The vee map is the hat map's inverse.

ManifoldsBase.number_of_coordinatesMethod
number_of_coordinates(M::Manifold, B::AbstractBasis)

Compute the number of coordinates in basis B of manifold M. This also corresponds to the number of vectors represented by B, or stored within B in case of a CachedBasis.

ManifoldsBase.veeMethod
vee(M::Manifold, p, X)

Given a basis $e_i$ on the tangent space at a point p and tangent vector X, compute the vector components $X^i$, such that $X = X^i e_i$, where Einstein summation notation is used:

\[\vee : X^i e_i ↦ X^i\]

For array manifolds, this converts an array representation of the tangent vector to a vector representation. The hat map is the vee map's inverse.

ManifoldsBase.AbstractBasisType
AbstractBasis{𝔽}

Abstract type that represents a basis on a manifold or a subset of it.

The type parameter 𝔽 denotes the AbstractNumbers that will be used for the vectors elements.

ManifoldsBase.allocation_promotion_functionMethod
allocation_promotion_function(M::Manifold, f, args::Tuple)

Determine the function that must be used to ensure that the allocated representation is of the right type. This is needed for get_vector when a point on a complex manifold is represented by a real-valued vectors with a real-coefficient basis, so that a complex-valued vector representation is allocated.

A Decorator for manifolds

A decorator manifold extends the functionality of a Manifold in a semi-transparent way. It internally stores the Manifold it extends and by default for functions defined in the ManifoldsBase it acts transparently in the sense that it passes all functions through to the base except those that it actually affects. For example, because the ValidationManifold affects nearly all functions, it overwrites nearly all functions, except a few like manifold_dimension. On the other hand, the MetricManifold only affects functions that involve metrics, especially exp and log but not the manifold_dimension. Contrary to the previous decorator, the MetricManifold does not overwrite functions. The decorator sets functions like exp and log to be implemented anew but required to be implemented when specifying a new metric. An exception is not issued if a metric is additionally set to be the default metric (see is_default_metric, since this makes all functions act transparently. this last case assumes that the newly specified metric type is actually the one already implemented on a manifold initially.

By default, i.e. for a plain new decorator, all functions are passed down. To implement a method for a decorator that behaves differently from the method of the same function for the internal manifold, two steps are required. Let's assume the function is called f(M, arg1, arg2), and our decorator manifold DM of type OurDecoratorManifold decorates M. Then

  1. set decorator_transparent_dispatch(f, M::OurDecoratorManifold, args...) = Val(:intransparent)
  2. implement f(DM::OurDecoratorManifold, arg1, arg2)

This makes it possible to extend a manifold or all manifolds with a feature or replace a feature of the original manifold. The MetricManifold is the best example of the second case, since the default metric indicates for which metric the manifold was originally implemented, such that those functions are just passed through. This can best be seen in the SymmetricPositiveDefinite manifold with its LinearAffineMetric.

ManifoldsBase.AbstractDecoratorManifoldType
AbstractDecoratorManifold{𝔽} <: Manifold{𝔽}

An AbstractDecoratorManifold indicates that to some extent a manifold subtype decorates another Manifold in the sense that it either

  • it extends the functionality of a manifold with further features
  • it defines a new manifold that internally uses functions from the decorated manifold

with the main intent that several or most functions of Manifold are transparently passed through to the manifold that is decorated. This way a function implemented for a decorator acts transparent on all other decorators, i.e. they just pass them through. If the decorator the function is implemented for is not among the decorators, an error is issued. By default all base manifold functions, for example exp and log are transparent for all decorators.

Transparency of functions with respect to decorators can be specified using the macros @decorator_transparent_fallback, @decorator_transparent_function and @decorator_transparent_signature.

ManifoldsBase.@decorator_transparent_fallbackMacro
@decorator_transparent_fallback(ex)
@decorator_transparent_fallback(fallback_case = :intransparent, ex)

This macro introduces an additional implementation for a certain additional case. This can especially be used if for an already transparent function and an abstract intermediate type a change in the default is required. For implementing a concrete type, neither this nor any other trick is necessary. One just implements the function as before. Note that a decorator that is_default_decorator still dispatches to the transparent case.

  • :transparent states, that the function is transparently passed on to the manifold that is decorated by the AbstractDecoratorManifold M, which is determined using the function decorated_manifold.
  • :intransparent states that an implementation for this decorator is required, and if none of the types provides one, an error is issued. Since this macro provides such an implementation, this is the default.
  • :parent states, that this function passes on to the supertype instead of to the decorated manifold.

Inline definitions are not supported. The function signature however may contain keyword arguments and a where clause. It does not allow for parameters with default values.

Examples

@decorator_transparent_fallback function log!(M::AbstractGroupManifold, X, p, q)
    log!(decorated_manifold(M), X, p, Q)
end
@decorator_transparent_fallback :transparent function log!(M::AbstractGroupManifold, X, p, q)
    log!(decorated_manifold(M), X, p, Q)
end
ManifoldsBase.@decorator_transparent_functionMacro
@decorator_transparent_function(ex)
@decorator_transparent_function(fallback_case = :intransparent, ex)

Introduce the function specified by ex to act transparently with respect to AbstractDecoratorManifolds. This introduces the possibility to modify the kind of transparency the implementation is done for. This optional first argument, the Symbol within fallback_case. This macro can be used to define a function and introduce it as transparent to other decorators. Note that a decorator that is_default_decorator still dispatches to the transparent case.

The cases of transparency are

  • :transparent states, that the function is transparently passed on to the manifold that is decorated by the AbstractDecoratorManifold M, which is determined using the function decorated_manifold.
  • :intransparent states that an implementation for this decorator is required, and if none of the types provides one, an error is issued. Since this macro provides such an implementation, this is the default.
  • :parent states, that this function passes on to the supertype instead of to the decorated manifold. Passing is performed using the invoke function where the type of manifold is replaced by its supertype.

Innkoline-definitions are not yet covered – the function signature however may contain keyword arguments and a where clause.

Examples

@decorator_transparent_function log!(M::AbstractDecoratorManifold, X, p, q)
    log!(decorated_manifold(M), X, p, Q)
end
@decorator_transparent_function :parent log!(M::AbstractDecoratorManifold, X, p, q)
    log!(decorated_manifold(M), X, p, Q)
end
ManifoldsBase.@decorator_transparent_signatureMacro
@decorator_transparent_signature(ex)

Introduces a given function to be transparent with respect to all decorators. The function is adressed by its signature in ex.

Supports standard, keyword arguments and where clauses. Doesn't support parameters with default values. It introduces a dispatch on several transparency modes

The cases of transparency are

  • :transparent states, that the function is transparently passed on to the manifold that is decorated by the AbstractDecoratorManifold M, which is determined using the function decorated_manifold. This is the default.
  • :intransparent states that an implementation for this decorator is required, and if none of the types provides one, an error is issued.
  • :parent states, that this function passes on to the supertype instead of to the decorated manifold.

Inline definitions are not supported. The function signature however may contain keyword arguments and a where clause.

The dispatch kind can later still be set to something different, see decorator_transparent_dispatch

Examples:

@decorator_transparent_signature log!(M::AbstractDecoratorManifold, X, p, q)
@decorator_transparent_signature log!(M::TD, X, p, q) where {TD<:AbstractDecoratorManifold}
@decorator_transparent_signature isapprox(M::AbstractDecoratorManifold, p, q; kwargs...)
ManifoldsBase.decorated_manifoldMethod
decorated_manifold(M::AbstractDecoratorManifold)

Return the manifold decorated by the decorator M. Defaults to M.manifold.

ManifoldsBase.is_decorator_transparentMethod
is_decorator_transparent(f, M::Manifold, args...) -> Bool

Given a Manifold M and a function f(M, args...), indicate, whether an AbstractDecoratorManifold acts transparently for f. This means, it just passes through down to the internally stored manifold. Transparency is only defined for decorator manifolds and by default all decorators are transparent. A function that is affected by the decorator indicates this by returning false. To change this behaviour, see decorator_transparent_dispatch.

If a decorator manifold is not in general transparent, it might still pass down for the case that a decorator is the default decorator, see is_default_decorator.

ManifoldsBase.is_default_decoratorMethod
is_default_decorator(M) -> Bool

For any manifold that is a subtype of AbstractDecoratorManifold, this function indicates whether a certain manifold M acts as a default decorator.

This yields that all functions are passed through to the decorated Manifold if M is indicated as default. This overwrites all is_decorator_transparent values.

This yields the following advantange: For a manifold one usually implicitly assumes for example a metric. To avoid reimplementation of this metric when introducing a second metric, the first metric can be set to be the default, i.e. its implementaion is already given by the undecorated case.

Value returned by this function is determined by default_decorator_dispatch, which returns a Val-wrapped boolean for type stability of certain functions.

ValidationManifold

ValidationManifold is a simple decorator that “decorates” a manifold with tests that all involved arrays are correct. For example involved input and output paratemers are checked before and after running a function, repectively. This is done by calling is_manifold_point or is_tangent_vector whenever applicable.

ManifoldsBase.ValidationManifoldType
ValidationManifold{𝔽,M<:Manifold{𝔽}} <: AbstractDecoratorManifold{𝔽}

A manifold to encapsulate manifolds working on array representations of MPoints and TVectors in a transparent way, such that for these manifolds it's not necessary to introduce explicit types for the points and tangent vectors, but they are encapsulated/stripped automatically when needed.

This manifold is a decorator for a manifold, i.e. it decorates a Manifold M with types points, vectors, and covectors.

EmbeddedManifold

Some manifolds can easily be defined by using a certain embedding. For example the Sphere(n) is embedded in Euclidean(n+1). Similar to the metric and MetricManifold, an embedding is often implicitly assumed. We introduce the embedded manifolds hence as an AbstractDecoratorManifold.

This decorator enables to use such an embedding in an transparent way. Different types of embeddings can be distinguished using the AbstractEmbeddingType.

The embedding also covers representation of tangent vectors. For both points and tangent vectors the function embed returns their representation in the embedding. For any point or vector in the embedding the functions project can be used to obtain the closest point on the manifold and tangent vector in the tangent space. Note that both embed and project may also be implemented on a Manifold already, assuming that the default implementation of that manifold has an (implicitly assumed) embedding. If there exists more than one embedding or to foster using functions from the embedding, like inner, this decorator can be employed. The different embeddings might also refer to different representations or parametrisations of an embedding. A specific example where embed and project actually do change the representation are Lie groups. Here, tangent vectors are often represented in the Lie algebra, i.e. in the tangent space of the identity element. Then, projection first projects onto a tangent space but also takes care to return the correct representation, i.e. the element from the Lie algebra corresponding to the projected tangent vector. Similarly, before embedding a tangent vector that is represented by an element from the Lie algebra, the group opration is applied.

Isometric Embeddings

For isometric embeddings the type AbstractIsometricEmbeddingType can be used to avoid reimplementing the metric. See Sphere or Hyperbolic for example. Here, the exponential map, the logarithmic map, the retraction and its inverse are set to :intransparent, i.e. they have to be implemented.

Furthermore, the TransparentIsometricEmbedding type even states that the exponential and logarithmic maps as well as retractions and vector transports of the embedding can be used for the embedded manifold as well. See SymmetricMatrices for an example.

In both cases of course check_manifold_point and check_tangent_vector have to be implemented.

Technical Details

Semantically we use the idea of the embedding to efficiently implement a manifold by not having to implement those functions that are already given by its embedding. Hence we decorate in some sense the manifold we implement. Still, technically base_manifold returns the embedding as long as EmbeddedManifold is used. For the abstract case, AbstractEmbeddedManifold the base manfiold might differ. Note that internally base_manifold uses decorated_manifold for one step of removing multiple decorators.

Clearly get_embedding always returns the embedding.

Types

ManifoldsBase.AbstractEmbeddedManifoldType
AbstractEmbeddedManifold{𝔽,T<:AbstractEmbeddingType,𝔽} <: AbstractDecoratorManifold{𝔽}

An abstract type for embedded manifolds, which acts as an AbstractDecoratorManifold. The functions of the manifold that is embedded can hence be just passed on to the embedding. The embedding is further specified by an AbstractEmbeddingType.

This means, that technically an embedded manifold is a decorator for the embedding, i.e. functions of this type get, in the semi-transparent way of the AbstractDecoratorManifold, passed on to the embedding.

ManifoldsBase.DefaultIsometricEmbeddingTypeType
DefaultIsometricEmbeddingType <: AbstractIsometricEmbeddingType

An isometric embedding type that acts as a default, i.e. it has no specifig properties beyond its isometric property.

ManifoldsBase.EmbeddedManifoldType
EmbeddedManifold{𝔽, MT <: Manifold, NT <: Manifold, ET} <: AbstractEmbeddedManifold{𝔽, ET}

A type to represent that a Manifold M of type MT is indeed an emebedded manifold and embedded into the manifold N of type NT. Based on the AbstractEmbeddingType ET, this introduces methods for M by passing them through to embedding N.

Fields

  • manifold the manifold that is an embedded manifold
  • embedding a second manifold, the first one is embedded into

Constructor

EmbeddedManifold(M, N, e=TransparentIsometricEmbedding())

Generate the EmbeddedManifold of the Manifold M into the Manifold N with AbstractEmbeddingType e that by default is the most transparent TransparentIsometricEmbedding

ManifoldsBase.TransparentIsometricEmbeddingType
TransparentIsometricEmbedding <: AbstractIsometricEmbeddingType

Specify that an embedding is the default isometric embedding. This even inherits logarithmic and exponential map as well as retraction and inverse retractions from the embedding.

For an example, see SymmetricMatrices which are isometrically embedded in the Euclidean space of matrices but also inherit exponential and logarithmic maps.

Functions

ManifoldsBase.base_manifoldMethod
base_manifold(M::AbstractEmbeddedManifold, d::Val{N} = Val(-1))

Return the base manifold of M that is enhanced with its embedding. While functions like inner might be overwritten to use the (decorated) manifold representing the embedding, the basemanifold is the manifold itself in the sense that detemining e.g. the [`isdefault_metric](@ref) does not fall back to check with the embedding but with the manifold itself. For this abstract case, justM` is returned.

ManifoldsBase.base_manifoldMethod
base_manifold(M::EmbeddedManifold, d::Val{N} = Val(-1))

Return the base manifold of M that is enhanced with its embedding. For this specific type the internally stored enhanced manifold M.manifold is returned.

ManifoldsBase.check_tangent_vectorMethod
check_tangent_vector(M::AbstractEmbeddedManifold, p, X; check_base_point = true, kwargs...)

check that embed(M,p,X) is a valid tangent to embed(p,X), where check_base_point determines whether the validity of p is checked, too.

DefaultManifold

DefaultManifold is a simplified version of Euclidean and demonstrates a basic interface implementation. It can be used to perform simple tests. Since when using Manifolds.jl the Euclidean is available, the DefaultManifold itself is not exported.

ManifoldsBase.DefaultManifoldType
DefaultManifold <: Manifold

This default manifold illustrates the main features of the interface and provides a skeleton to build one's own manifold. It is a simplified/shortened variant of Euclidean from Manifolds.jl.

This manifold further illustrates how to type your manifold points and tangent vectors. Note that the interface does not require this, but it might be handy in debugging and educative situations to verify correctness of involved variabes.