Retractions and inverse Retractions
The exponential and logarithmic map might be too expensive to evaluate or not be available in a very stable numerical way on certain manifolds $\mathcal M$. Retractions provide a possibly cheap, fast and stable alternative.
A retraction $\operatorname{retr}_p: T_p\mathcal M → \mathcal M$ is a smooth map that fulfils (for all $p\in\mathcal M$) that
- $\operatorname{retr}_p(0) = p$
- $D\operatorname{retr}_p(0): T_p\mathcal M \to T_p\mathcal M$ is the identity map,
i.e. $D\operatorname{retr}_p(0)[X]=X$ holds for all $X\in T_p\mathcal M$,
where $D\operatorname{retr}_p$ denotes the differential of the retraction.
A retraction $\operatorname{retr}_p$ can be interpreted as a first order approximation to the exponential map $\exp_p$.
The retraction is called of second order if for all $X$ the curves $c(t) = R_p(tX)$ have a zero acceleration at $t=0$, i.e. $c''(0) = 0$.
The following figure compares the exponential map exp
(M, p, X)
on the Circle (ℂ)
(or Sphere
(1)
embedded in $ℝ^2$ with one possible retraction, the one based on projections. Note especially that $\operatorname{dist}(p,q)=\lVert X\rVert_p$ while this is not the case for the result $\operatorname{retr}_p(X) = q'$.
Similar to the exp
onential map the retract
ion might not be globally invertible, but locally it is. So locally one can define the inverse retraction $\operatorname{retr}_p^{-1}\colon \mathcal M \to T_p\mathcal M$, which can be seen as a first order approximation to the log
arithmic map. Within the ManifoldsBase.jl
interface the inverse retraction is called inverse_retract
.
The general interface looks as follows.
ManifoldsBase.default_inverse_retraction_method
— Methoddefault_inverse_retraction_method(M::AbstractManifold)
default_inverse_retraction_method(M::AbstractManifold, ::Type{T}) where {T}
The AbstractInverseRetractionMethod
that is used when calling inverse_retract
without specifying the inverse retraction method. By default, this is the LogarithmicInverseRetraction
.
This method can also be specified more precisely with a point type T
, for the case that on a M
there are two different representations of points, which provide different inverse retraction methods.
ManifoldsBase.default_retraction_method
— Methoddefault_retraction_method(M::AbstractManifold)
default_retraction_method(M::AbstractManifold, ::Type{T}) where {T}
The AbstractRetractionMethod
that is used when calling retract
without specifying the retraction method. By default, this is the ExponentialRetraction
.
This method can also be specified more precisely with a point type T
, for the case that on a M
there are two different representations of points, which provide different retraction methods.
ManifoldsBase.inverse_retract
— Functioninverse_retract(M::AbstractManifold, p, q)
inverse_retract(M::AbstractManifold, p, q, method::AbstractInverseRetractionMethod
Compute the inverse retraction, a cheaper, approximate version of the log
arithmic map), of points p
and q
on the AbstractManifold
M
.
Inverse retraction method can be specified by the last argument, defaulting to default_inverse_retraction_method
(M)
. For available inverse retractions on certain manifolds see the documentation on the corresponding manifold.
See also retract
.
ManifoldsBase.inverse_retract!
— Functioninverse_retract!(M::AbstractManifold, X, p, q[, method::AbstractInverseRetractionMethod])
Compute the inverse retraction, a cheaper, approximate version of the log
arithmic map), of points p
and q
on the AbstractManifold
M
. Result is saved to X
.
Inverse retraction method can be specified by the last argument, defaulting to default_inverse_retraction_method
(M)
. See the documentation of respective manifolds for available methods.
See also retract!
.
ManifoldsBase.retract
— Functionretract(M::AbstractManifold, p, X, method::AbstractRetractionMethod=default_retraction_method(M, typeof(p)))
retract(M::AbstractManifold, p, X, t::Number=1, method::AbstractRetractionMethod=default_retraction_method(M, typeof(p)))
Compute a retraction, a cheaper, approximate version of the exp
onential map, from p
into direction X
, scaled by t
, on the AbstractManifold
M
.
A retraction $\operatorname{retr}_p: T_p\mathcal M → \mathcal M$ is a smooth map that fulfils
- $\operatorname{retr}_p(0) = p$
- $D\operatorname{retr}_p(0): T_p\mathcal M \to T_p\mathcal M$ is the identity map,
i.e. $D\operatorname{retr}_p(0)[X]=X$ holds for all $X\in T_p\mathcal M$,
where $D\operatorname{retr}_p$ denotes the differential of the retraction
The retraction is called of second order if for all $X$ the curves $c(t) = R_p(tX)$ have a zero acceleration at $t=0$, i.e. $c''(0) = 0$.
Retraction method can be specified by the last argument, defaulting to default_retraction_method
(M)
. For further available retractions see the documentation of respective manifolds.
Locally, the retraction is invertible. For the inverse operation, see inverse_retract
.
ManifoldsBase.retract!
— Functionretract!(M::AbstractManifold, q, p, X)
retract!(M::AbstractManifold, q, p, X, t::Real=1)
retract!(M::AbstractManifold, q, p, X, method::AbstractRetractionMethod)
retract!(M::AbstractManifold, q, p, X, t::Real=1, method::AbstractRetractionMethod)
Compute a retraction, a cheaper, approximate version of the exp
onential map, from p
into direction X
, scaled by t
, on the AbstractManifold
manifold M
. Result is saved to q
.
Retraction method can be specified by the last argument, defaulting to default_retraction_method
(M)
. See the documentation of respective manifolds for available methods.
See retract
for more details.
Types of Retractions
To distinguish different types of retractions, the last argument of the retraction as well as its inverse specifies a type. The following ones are available.
ManifoldsBase.AbstractInverseRetractionMethod
— TypeAbstractInverseRetractionMethod
Abstract type for methods for inverting a retraction (see inverse_retract
).
ManifoldsBase.AbstractRetractionMethod
— TypeAbstractRetractionMethod
Abstract type for methods for retract
ing a tangent vector to a manifold.
ManifoldsBase.ApproximateInverseRetraction
— TypeApproximateInverseRetraction <: AbstractInverseRetractionMethod
An abstract type for representing approximate inverse retraction methods.
ManifoldsBase.ApproximateRetraction
— TypeApproximateRetraction <: AbstractInverseRetractionMethod
An abstract type for representing approximate retraction methods.
ManifoldsBase.CayleyInverseRetraction
— TypeCayleyInverseRetraction <: AbstractInverseRetractionMethod
A retraction based on the Cayley transform, which is realized by using the PadeRetraction
{1}
.
ManifoldsBase.CayleyRetraction
— TypeCayleyRetraction <: AbstractRetractionMethod
A retraction based on the Cayley transform, which is realized by using the PadeRetraction
{1}
.
ManifoldsBase.EmbeddedInverseRetraction
— TypeEmbeddedInverseRetraction{T<:AbstractInverseRetractionMethod} <: AbstractInverseRetractionMethod
Compute an inverse retraction by using the inverse retraction of type T
in the embedding and projecting the result
Constructor
EmbeddedInverseRetraction(r::AbstractInverseRetractionMethod)
Generate the inverse retraction with inverse retraction r
to use in the embedding.
ManifoldsBase.EmbeddedRetraction
— TypeEmbeddedRetraction{T<:AbstractRetractionMethod} <: AbstractRetractionMethod
Compute a retraction by using the retraction of type T
in the embedding and projecting the result.
Constructor
EmbeddedRetraction(r::AbstractRetractionMethod)
Generate the retraction with retraction r
to use in the embedding.
ManifoldsBase.ExponentialRetraction
— TypeExponentialRetraction <: AbstractRetractionMethod
Retraction using the exponential map.
ManifoldsBase.InverseRetractionWithKeywords
— TypeInverseRetractionWithKeywords{R<:AbstractRetractionMethod,K} <: AbstractRetractionMethod
Since inverse retractions might have keywords, this type is a way to set them as an own type to be used as a specific inverse retraction. Another reason for this type is that we dispatch on the inverse retraction first and only the last layer would be implemented with keywords, so this way they can be passed down.
Fields
inverse_retraction
the inverse retraction that is decorated with keywordskwargs
the keyword arguments
Note that you can nest this type. Then the most outer specification of a keyword is used.
Constructor
InverseRetractionWithKeywords(m::T; kwargs...) where {T <: AbstractInverseRetractionMethod}
Specify the subtype T <:
AbstractInverseRetractionMethod
to have keywords kwargs...
.
ManifoldsBase.LogarithmicInverseRetraction
— TypeLogarithmicInverseRetraction <: AbstractInverseRetractionMethod
Inverse retraction using the log
arithmic map.
ManifoldsBase.NLSolveInverseRetraction
— TypeNLSolveInverseRetraction{T<:AbstractRetractionMethod,TV,TK} <:
ApproximateInverseRetraction
An inverse retraction method for approximating the inverse of a retraction using NLsolve
.
Constructor
NLSolveInverseRetraction(
method::AbstractRetractionMethod[, X0];
project_tangent=false,
project_point=false,
nlsolve_kwargs...,
)
Constructs an approximate inverse retraction for the retraction method
with initial guess X0
, defaulting to the zero vector. If project_tangent
is true
, then the tangent vector is projected before the retraction using project
. If project_point
is true
, then the resulting point is projected after the retraction. nlsolve_kwargs
are keyword arguments passed to NLsolve.nlsolve
.
ManifoldsBase.ODEExponentialRetraction
— TypeODEExponentialRetraction{T<:AbstractRetractionMethod, B<:AbstractBasis} <: AbstractRetractionMethod
Approximate the exponential map on the manifold by evaluating the ODE descripting the geodesic at 1, assuming the default connection of the given manifold by solving the ordinary differential equation
\[\frac{d^2}{dt^2} p^k + Γ^k_{ij} \frac{d}{dt} p_i \frac{d}{dt} p_j = 0,\]
where $Γ^k_{ij}$ are the Christoffel symbols of the second kind, and the Einstein summation convention is assumed.
Constructor
ODEExponentialRetraction(
r::AbstractRetractionMethod,
b::AbstractBasis=DefaultOrthogonalBasis(),
)
Generate the retraction with a retraction to use internally (for some approaches) and a basis for the tangent space(s).
ManifoldsBase.PadeInverseRetraction
— TypePadeInverseRetraction{m} <: AbstractRetractionMethod
An inverse retraction based on the Padé approximation of order $m$ for the retraction.
ManifoldsBase.PadeRetraction
— TypePadeRetraction{m} <: AbstractRetractionMethod
A retraction based on the Padé approximation of order $m$
ManifoldsBase.PolarInverseRetraction
— TypePolarInverseRetraction <: AbstractInverseRetractionMethod
Inverse retractions that are based on a singular value decomposition of the matrix / matrices for point and tangent vector on a AbstractManifold
ManifoldsBase.PolarRetraction
— TypePolarRetraction <: AbstractRetractionMethod
Retractions that are based on singular value decompositions of the matrix / matrices for point and tangent vector on a AbstractManifold
ManifoldsBase.ProjectionInverseRetraction
— TypeProjectionInverseRetraction <: AbstractInverseRetractionMethod
Inverse retractions that are based on a projection (or its inversion).
ManifoldsBase.ProjectionRetraction
— TypeProjectionRetraction <: AbstractRetractionMethod
Retractions that are based on projection and usually addition in the embedding.
ManifoldsBase.QRInverseRetraction
— TypeQRInverseRetraction <: AbstractInverseRetractionMethod
Inverse retractions that are based on a QR decomposition of the matrix / matrices for point and tangent vector on a AbstractManifold
ManifoldsBase.QRRetraction
— TypeQRRetraction <: AbstractRetractionMethod
Retractions that are based on a QR decomposition of the matrix / matrices for point and tangent vector on a AbstractManifold
ManifoldsBase.RetractionWithKeywords
— TypeRetractionWithKeywords{R<:AbstractRetractionMethod,K} <: AbstractRetractionMethod
Since retractions might have keywords, this type is a way to set them as an own type to be used as a specific retraction. Another reason for this type is that we dispatch on the retraction first and only the last layer would be implemented with keywords, so this way they can be passed down.
Fields
retraction
the retraction that is decorated with keywordskwargs
the keyword arguments
Note that you can nest this type. Then the most outer specification of a keyword is used.
Constructor
RetractionWithKeywords(m::T; kwargs...) where {T <: AbstractRetractionMethod}
Specify the subtype T <:
AbstractRetractionMethod
to have keywords kwargs...
.
ManifoldsBase.SoftmaxInverseRetraction
— TypeSoftmaxInverseRetraction <: AbstractInverseRetractionMethod
Describes an inverse retraction that is based on the softmax function.
ManifoldsBase.SoftmaxRetraction
— TypeSoftmaxRetraction <: AbstractRetractionMethod
Describes a retraction that is based on the softmax function.
ManifoldsBase.ShootingInverseRetraction
— TypeShootingInverseRetraction <: ApproximateInverseRetraction
Approximating the inverse of a retraction using the shooting method.
This implementation of the shooting method works by using another inverse retraction to form the first guess of the vector. This guess is updated by shooting the vector, guessing the vector pointing from the shooting result to the target point, and transporting this vector update back to the initial point on a discretized grid. This process is repeated until the norm of the vector update falls below a specified tolerance or the maximum number of iterations is reached.
Fields
retraction::AbstractRetractionMethod
: The retraction whose inverse is approximated.initial_inverse_retraction::AbstractInverseRetractionMethod
: The inverse retraction used to form the initial guess of the vector.vector_transport::AbstractVectorTransportMethod
: The vector transport used to transport the initial guess of the vector.num_transport_points::Int
: The number of discretization points used for vector transport in the shooting method. 2 is the minimum number of points, including just the endpoints.tolerance::Real
: The tolerance for the shooting method.max_iterations::Int
: The maximum number of iterations for the shooting method.
The functions on layer 3
While you should always add your documentation to retract
or retract!
when implementing new manifolds, the actual implementation happens on the following functions on layer III.
ManifoldsBase.inverse_retract_cayley!
— Methodinverse_retract_cayley!(M::AbstractManifold, X, p, q)
Compute the in-place variant of the CayleyInverseRetraction
, which by default calls the first order [PadeInverseRetraction
§(@ref).
ManifoldsBase.inverse_retract_cayley
— Methodinverse_retract_cayley(M::AbstractManifold, p, q)
computes the allocating variant of the CayleyInverseRetraction
, which by default allocates and calls inverse_retract_cayley!
.
ManifoldsBase.inverse_retract_embedded!
— Methodinverse_retract_embedded!(M::AbstractManifold, X, p, q, m::AbstractInverseRetractionMethod)
Compute the in-place variant of the EmbeddedInverseRetraction
using the AbstractInverseRetractionMethod
m
in the embedding (see get_embedding
) and projecting the result back.
ManifoldsBase.inverse_retract_embedded
— Methodinverse_retract_embedded(M::AbstractManifold, p, q, m::AbstractInverseRetractionMethod)
computes the allocating variant of the EmbeddedInverseRetraction
using the AbstractInverseRetractionMethod
m
in the embedding (see get_embedding
) and projecting the result back.
ManifoldsBase.inverse_retract_nlsolve!
— Methodinverse_retract_nlsolve!(M::AbstractManifold, X, p, q, m::NLSolveInverseRetraction)
Compute the in-place variant of the NLSolveInverseRetraction
m
.
ManifoldsBase.inverse_retract_nlsolve
— Methodinverse_retract_nlsolve(M::AbstractManifold, p, q, m::NLSolveInverseRetraction)
computes the allocating variant of the NLSolveInverseRetraction
m
, which by default allocates and calls inverse_retract_nlsolve!
.
ManifoldsBase.inverse_retract_pade!
— Methodinverse_retract_pade!(M::AbstractManifold, p, q, n)
Compute the in-place variant of the PadeInverseRetraction
(n)
,
ManifoldsBase.inverse_retract_pade
— Methodinverse_retract_pade(M::AbstractManifold, p, q)
computes the allocating variant of the PadeInverseRetraction
(n)
, which by default allocates and calls inverse_retract_pade!
.
ManifoldsBase.inverse_retract_polar!
— Methodinverse_retract_polar!(M::AbstractManifold, X, p, q)
Compute the in-place variant of the PolarInverseRetraction
.
ManifoldsBase.inverse_retract_polar
— Methodinverse_retract_polar(M::AbstractManifold, p, q)
computes the allocating variant of the PolarInverseRetraction
, which by default allocates and calls inverse_retract_polar!
.
ManifoldsBase.inverse_retract_project!
— Methodinverse_retract_project!(M::AbstractManifold, X, p, q)
Compute the in-place variant of the ProjectionInverseRetraction
.
ManifoldsBase.inverse_retract_project
— Methodinverse_retract_project(M::AbstractManifold, p, q)
computes the allocating variant of the ProjectionInverseRetraction
, which by default allocates and calls inverse_retract_project!
.
ManifoldsBase.inverse_retract_qr!
— Methodinverse_retract_qr!(M::AbstractManifold, X, p, q)
Compute the in-place variant of the QRInverseRetraction
.
ManifoldsBase.inverse_retract_qr
— Methodinverse_retract_qr(M::AbstractManifold, p, q)
computes the allocating variant of the QRInverseRetraction
, which by default allocates and calls inverse_retract_qr!
.
ManifoldsBase.inverse_retract_softmax!
— Methodinverse_retract_softmax!(M::AbstractManifold, X, p, q)
Compute the in-place variant of the SoftmaxInverseRetraction
.
ManifoldsBase.inverse_retract_softmax
— Methodinverse_retract_softmax(M::AbstractManifold, p, q)
computes the allocating variant of the SoftmaxInverseRetraction
, which by default allocates and calls inverse_retract_softmax!
.
ManifoldsBase.retract_cayley!
— Methodretract_cayley!(M::AbstractManifold, q, p, X, t::Number)
Compute the in-place variant of the CayleyRetraction
, which by default falls back to calling the first order PadeRetraction
.
ManifoldsBase.retract_cayley
— Methodretract_cayley(M::AbstractManifold, p, X, t::Number)
Compute the allocating variant of the CayleyRetraction
, which by default allocates and calls retract_cayley!
.
ManifoldsBase.retract_embedded!
— Methodretract_embedded!(M::AbstractManifold, q, p, X, t::Number, m::AbstractRetractionMethod)
Compute the in-place variant of the EmbeddedRetraction
using the AbstractRetractionMethod
m
in the embedding (see get_embedding
) and projecting the result back.
ManifoldsBase.retract_embedded
— Methodretract_embedded(M::AbstractManifold, p, X, t::Number, m::AbstractRetractionMethod)
computes the allocating variant of the EmbeddedRetraction
using the AbstractRetractionMethod
m
in the embedding (see get_embedding
) and projecting the result back.
ManifoldsBase.retract_exp_ode!
— Methodretract_exp_ode!(M::AbstractManifold, q, p, X, t::Number, m::AbstractRetractionMethod, B::AbstractBasis)
Compute the in-place variant of the ODEExponentialRetraction
(m, B)
.
ManifoldsBase.retract_exp_ode
— Methodretract_exp_ode(M::AbstractManifold, p, q, m::AbstractRetractionMethod, B::AbstractBasis)
Compute the allocating variant of the ODEExponentialRetraction
(m,B)
, which by default allocates and calls retract_exp_ode!
.
ManifoldsBase.retract_pade!
— Methodretract_pade!(M::AbstractManifold, q, p, X, t::Number, m::PadeRetraction)
Compute the in-place variant of the PadeRetraction
m
.
ManifoldsBase.retract_pade
— Methodretract_pade(M::AbstractManifold, p, X, t::Number, m::PadeRetraction)
Compute the allocating variant of the PadeRetraction
m
, which by default allocates and calls retract_pade!
.
ManifoldsBase.retract_polar!
— Methodretract_polar!(M::AbstractManifold, q, p, X, t::Number)
Compute the in-place variant of the PolarRetraction
.
ManifoldsBase.retract_polar
— Methodretract_polar(M::AbstractManifold, p, X, t::Number)
computes the allocating variant of the PolarRetraction
, which by default allocates and calls retract_polar!
.
ManifoldsBase.retract_project!
— Methodretract_project!(M::AbstractManifold, q, p, X, t::Number)
Compute the in-place variant of the ProjectionRetraction
.
ManifoldsBase.retract_project
— Methodretract_project(M::AbstractManifold, p, X, t::Number)
Compute the allocating variant of the ProjectionRetraction
, which by default allocates and calls retract_project!
.
ManifoldsBase.retract_qr!
— Methodretract_qr!(M::AbstractManifold, q, p, X, t::Number)
Compute the in-place variant of the QRRetraction
.
ManifoldsBase.retract_qr
— Methodretract_qr(M::AbstractManifold, p, X, t::Number)
Compute the allocating variant of the QRRetraction
, which by default allocates and calls retract_qr!
.
ManifoldsBase.retract_softmax!
— Methodretract_softmax!(M::AbstractManifold, q, p, X, t::Number)
Compute the in-place variant of the SoftmaxRetraction
.
ManifoldsBase.retract_softmax
— Methodretract_softmax(M::AbstractManifold, p, X, t::Number)
Compute the allocating variant of the SoftmaxRetraction
, which by default allocates and calls retract_softmax!
.
ManifoldsBase.inverse_retract_shooting
— Methodinverse_retract_shooting(M::AbstractManifold, p, q, m::ShootingInverseRetraction)
Approximate the inverse of a retraction using the shooting method.