Retractions API
The retractions, the exponential algorithms behind them, and vector transport.
GeometricOptimizers.AbstractExponentialAlgorithm — Type
AbstractExponentialAlgorithmSupertype of the algorithms that Geodesic can use to evaluate the matrix exponential.
A horizontal lift factors as $\bar{B} = B'(B'')^T$ into two $N\times{}2n$ matrices. Since $(B'(B'')^T)^k = B'X^{k-1}(B'')^T$ for $X=(B'')^TB'$, substituting into the exponential series gives
\[\exp(B'(B'')^T) = \mathbb{I} + B'\,\mathfrak{A}((B'')^TB')\,(B'')^T, \qquad \mathfrak{A}(X) = \sum_{n=1}^\infty \frac{X^{n-1}}{n!},\]
Computing $\mathfrak{A}(X)$ is therefore the central numerical task: it preserves the low-rank factorization and reduces the matrix function from $N\times{}N$ to $2n\times{}2n$. $\mathfrak{A}$ is the notation of this implementation and of [15]; the exponential-integrator literature writes the same function $\varphi_1$ [26, §2.1].
Four subtypes evaluate that $2n\times{}2n$ function, while ProjectedSkew bypasses it and exponentiates the lift in a basis of its range. They compute the same exponential map — so the one-parameter subgroup property Geodesic relies on holds for all of them — but differ in their approximation kernel, recovery strategy, numerical behaviour, cost, and backend requirements.
ScaledSquaring is the default, and the cheapest algorithm with no dense-LAPACK dependency. Reach for another only if you need what it gives you: NativePade an independent direct calculation, ProjectedSkew orthogonality that does not degrade with the size of the lift, AugmentedPade a dense-CPU reference that delegates its numerics to Base.exp. TaylorSeries is the unscaled series, kept as a baseline; it is not a usable retraction.
The Exponential Algorithms page derives all five, measures them against each other, and says which to choose in Choosing one. Its tables are recomputed on every documentation build, so they, and not a figure quoted in a docstring, are what to trust.
A new one has to supply 𝔄(X::AbstractMatrix, ::NewAlgorithm); geodesic and everything above it then follow. An algorithm that does not go through $\mathfrak{A}$ at all — ProjectedSkew is the one such — supplies geodesic(::AbstractLieAlgHorMatrix, ::NewAlgorithm) instead.
See GeometricOptimizers.𝔄 for the implementations.
GeometricOptimizers.AugmentedPade — Type
AugmentedPade <: AbstractExponentialAlgorithmEvaluate $\mathfrak{A}$ as a block of a larger ordinary exponential.
This is an independent dense-CPU reference for testing the direct implementations, not the normal choice for a retraction.
\[\exp\begin{pmatrix} X & \mathbb{I} \\ \mathbb{O} & \mathbb{O} \end{pmatrix} = \begin{pmatrix} \exp(X) & \mathfrak{A}(X) \\ \mathbb{O} & \mathbb{I} \end{pmatrix}\]
so one call to Base.exp on a $4n\times{}4n$ matrix returns $\mathfrak{A}(X)$ in its upper-right block. That hands the numerics to Julia's own dense matrix exponential, which uses a Padé-based scaling-and-squaring algorithm [23, 24], at the cost of exponentiating a matrix four times the size and discarding three quarters of it.
Its value is that it introduces no package-specific approximation, which is what makes it the reference the other algorithms are measured against, both in the test suite and in every accuracy table on the Exponential Algorithms page. Its accuracy is the same order as ScaledSquaring's; what it costs is the work it throws away.
Base.exp on a dense matrix needs LAPACK. ScaledSquaring and NativePade avoid that dependency, subject to backend support for their matrix operations.
See 4. AugmentedPade for the measurements and AbstractExponentialAlgorithm for the alternatives.
GeometricOptimizers.NativePade — Type
NativePade(θ = 0.5) <: AbstractExponentialAlgorithmEvaluate $\mathfrak{A}$ with a native degree-6 diagonal Padé approximant.
This scales and squares too. The name distinguishes the kernel and not the algorithm's relationship to scaling: NativePade and ScaledSquaring choose s by the same rule and undo it with the same $s$ applications of $W \mapsto 2W + WXW$, and differ only in what they evaluate at the scaled argument. The two are not alternatives.
Scaling controls the large-argument cancellation that makes TaylorSeries unreliable. At the resulting small argument there is still a choice of approximation kernel, and that choice is what this type makes. Where a degree-6 Taylor polynomial matches the series of $\mathfrak{A}$ through order 6, the $[6/6]$ rational function $p_6/q_6$ derived from the classical $[7/6]$ approximant of $\exp$ matches it through order 12 at the same polynomial degree. The denominator is applied by five Newton–Schulz steps [32] rather than by a dense solve, which is what keeps the algorithm free of LAPACK — matrix products and reductions only, so whether it runs on a given accelerator depends on that backend's support for those. That is what makes it the independent cross-check available where AugmentedPade, the dense-CPU reference, is not.
θ is a ceiling here, not a preference as it is for ScaledSquaring. The Newton–Schulz count is fixed at five, and their residual is below round-off only while the argument is small: the bound $\|Y\|_1 \leq 1/2$ gives $\|I - q_6(Y)\|_1 < 0.257$ and hence a final residual below $1.3\cdot10^{-19}$. Past $θ \approx 1$ the inverse it computes stops being one, and it fails silently — nothing in the result says so. The constructor therefore requires $0 < θ \leq 1/2$, where ScaledSquaring accepts any positive value: the two thresholds are not interchangeable. Lowering this one is safe and adds modified-squaring steps, which is why it is a parameter at all.
$θ = 1/2$ is not taken from a backward-error table. The $\theta_m$ of [23, 24] are derived for $\exp$ rather than for $\mathfrak{A}$, and they bound a backward error in $\|X\|$ — the least informative norm available here, since $\|X\|$ is quadratic in $\|\bar{B}\|_2$ against a spectral radius of exactly $\|\bar{B}\|_2$ (see the note under ScaledSquaring). What justifies this threshold is narrower: the Newton–Schulz residual bound above, and the measured forward error. A backward-error criterion for $\mathfrak{A}$ on an argument that far from normal is not settled here.
3. Padé approximation derives the coefficients, the Newton–Schulz iteration and the residual bound, gives the algorithm step by step, and measures the error at a larger $θ$ at build time in What a large $\theta$ costs NativePade. See AbstractExponentialAlgorithm for the comparison.
GeometricOptimizers.ProjectedSkew — Type
ProjectedSkew <: AbstractExponentialAlgorithmExponentiate the lift in a basis of its own range, where it is a small skew-symmetric matrix.
$\bar{B}$ is skew-symmetric of rank at most $2n$, so its range and its row space coincide and a thin QR of $B'$ gives an $N\times{}2n$ orthonormal Q with $\bar{B} = QMQ^T$ for $M = Q^T\bar{B}Q$ skew-symmetric and $2n\times{}2n$. Then
\[\exp(\bar{B}) = \mathbb{I} + Q\left(\exp(M) - \mathbb{I}\right)Q^T,\]
and $\exp(M)$ is formed from an eigendecomposition: $iM$ is Hermitian for real skew $M$, so $M = -iV\Lambda{}V^*$ and $\exp(M) = \Re\left(V e^{-i\Lambda} V^*\right)$, which is orthogonal by construction rather than by cancellation.
This is the only algorithm whose check does not degrade with the size of the lift, because its orthogonality is structural — it comes from the eigenvector matrix, not from the accuracy of a series. The gap is widest in Float32, where the other four climb into the $10^{-5}$s while this one stays in the $10^{-6}$s from one end of the norm sweep to the other.
The trade is the forward error against exp(Matrix(B)), the largest of the four at all but the very largest lifts, and a QR plus an eigendecomposition instead of matrix products. Choose it when staying on the manifold matters more than agreeing with the exponential to the last bit — a long Float32 run, for instance, where check accumulates over thousands of steps.
Every step runs on the lift's own backend, so the backend has to supply a qr and an eigen of a Hermitian matrix for its dense arrays. LAPACK does on the host, and CUDA.jl provides both through cuSOLVER, which this package does not test. Metal and JLArrays supply neither, and there the call raises inside qr. ScaledSquaring needs matrix products only, and NativePade a solve besides.
See 5. ProjectedSkew for the measurements and AbstractExponentialAlgorithm for the alternatives.
GeometricOptimizers.ScaledSquaring — Type
ScaledSquaring(θ = 0.5) <: AbstractExponentialAlgorithmEvaluate $\mathfrak{A}$ with a Taylor kernel and low-rank modified squaring, and the default.
This is not the Padé kernel used by the conventional dense matrix-exponential algorithm. Its improvement over TaylorSeries is that it first scales the argument into a regime where the same Taylor evaluator is accurate, then recovers the original argument with a recurrence specialized to the low-rank factorization [25].
The series for $\mathfrak{A}$ converges for every argument but is only accurate for a small one, so the argument is halved the smallest number $s$ of times with $\|X\|_1/2^s \leq θ$, the series is summed there, and each halving is undone by one application of $W \mapsto 2W + WXW$. That recurrence is the modified squaring of [25]; it stays at $2n\times{}2n$ because the low-rank form is closed under squaring, so nothing is ever squared at $N\times{}N$. The recovery steps are exact identities, so scaling moves where Taylor is evaluated without changing the function computed.
θ is the norm threshold the kernel sees. Smaller values use more scaling steps; larger values evaluate the series at a larger argument. The default 0.5 needs no tuning: across the 32-fold range $θ \in [0.125, 4]$ neither the orthogonality of the retracted point nor the error against exp moves by as much as a factor of six, and neither moves monotonically. Unlike NativePade's, this threshold is a preference and not a ceiling, because the inner series is summed to vanishing terms rather than for a fixed number of steps.
This is the cheapest of the five, and it needs neither dense LAPACK nor scalar indexing in package code — whether it runs on a given accelerator depends on that backend's support for matrix products and reductions. What it gives up is that its orthogonality is an arithmetic outcome rather than a structural property, so check drifts upwards with the size of the lift; only ProjectedSkew avoids that.
$\|X\|_2$ grows like $\|\bar{B}\|_2^2$ while $\rho(X) = \|\bar{B}\|_2$ exactly, so $X$ is far from normal. That is why the unscaled series does worse here than it would on $\bar{B}$ itself, and why s grows like $2\log_2\|\bar{B}\|_2$ rather than $\log_2\|\bar{B}\|_2$. Why the reduced argument is the hard case derives and measures both.
2. Scaling and modified squaring gives the algorithm step by step, with the identity behind the recurrence and the measurements behind every claim above. See AbstractExponentialAlgorithm for the alternatives.
GeometricOptimizers.TaylorSeries — Type
TaylorSeries <: AbstractExponentialAlgorithmSum the series for $\mathfrak{A}$ directly, without scaling. This is not a usable retraction.
It is kept so that the working algorithms have a baseline to be compared against, in the test suite and in the manual. The series is summed on $X = (B'')^TB'$, and that reduced matrix is far from normal: its norm is quadratic in $\|\bar{B}\|_2$ where its spectral radius is exactly $\|\bar{B}\|_2$. On such an argument the terms cancel, so stopping when a term falls below eps leaves an error of size $\varepsilon\max_m\|S_m\|$ rather than $\varepsilon\|\mathfrak{A}(X)\|$, where $S_m$ are the partial sums. By $\|\bar{B}\| \approx 79$ the partial sums exceed the result by twenty orders of magnitude and the "retracted" point is not on the Stiefel manifold in any sense; by $\|\bar{B}\| \approx 770$ the summation has overflowed.
The failure is silent: nothing reports that the result is off the manifold. check is what detects it, and no optimizer in this package calls it during a run. Making the termination test relative to the partial sum instead of absolute changes none of it: the loss is in the cancellation, not in when the summation stops.
Use ScaledSquaring, which fixes this and is also the cheaper of the two, because the scaled series converges in a handful of terms where the unscaled one grinds through hundreds.
1. Direct Taylor series derives the failure and tabulates it over the whole norm sweep. See AbstractExponentialAlgorithm for the alternatives.
GeometricOptimizers.ScaledAlgorithm — Type
ScaledAlgorithmThe AbstractExponentialAlgorithms built as a small-argument kernel inside scaling and modified squaring, i.e. ScaledSquaring and NativePade. They share the θ field and the 𝔄! method below, and differ only in their _scaled_kernel!.
GeometricOptimizers._native_pade_polynomials — Method
_native_pade_polynomials(X, 𝕀)Evaluate the degree-6 numerator $p_6(X)$ and denominator $q_6(X)$ used by NativePade. It allocates its result and scratch and calls _native_pade_polynomials!, which writes into given arrays.
If $P^{\exp}_7/Q^{\exp}_6$ is the $[7/6]$ Padé approximant of the exponential, then
\[p_6(z)=\frac{P^{\exp}_7(z)-Q^{\exp}_6(z)}{z}, \qquad q_6(z)=Q^{\exp}_6(z),\]
so $q_6(X)^{-1}p_6(X)$ agrees with $\mathfrak{A}(X)$ through the $X^{12}$ term. The implementation shares $X^2$ and $X^4$ between the two polynomials and groups the remaining terms to avoid forming every matrix power separately. 𝕀 must be the multiplicative identity with the same size, element type, and backend as X.
This is an internal kernel; NativePade supplies scaling, applies the denominator, and undoes the scaling with modified squaring.
GeometricOptimizers._scaled_kernel! — Method
_scaled_kernel!(scratch, X, algorithm)Evaluate $\mathfrak{A}(X)$ for $\|X\|_1 \leq θ$ into scratch.𝔄X, i.e. the small-argument kernel that ScaledSquaring and NativePade differ in.
ScaledSquaring sums the Taylor series, NativePade evaluates the $[6/6]$ Padé approximant. Everything else the two algorithms do — choosing the number of halvings, and undoing them — is the shared framework in 𝔄!(::Any, ::AbstractMatrix, ::ScaledAlgorithm) below. scratch is as there.
GeometricOptimizers.opnorm₁ — Method
opnorm₁(X)The induced 1-norm of X, i.e. its largest absolute column sum, as a reduction.
LinearAlgebra.opnorm(X, 1) is the natural spelling and is not used, because LinearAlgebra.opnorm1 is a double loop over X[i, j]. Scalar indexing is precisely what an array on a GPU backend cannot serve, and being free of it is why ScaledSquaring and NativePade have no dense-LAPACK dependency at all — so the one norm they take has to be expressible as sum and maximum. Accelerator execution still depends on the array backend's support for those reductions.
The two algorithms do not call opnorm₁: GeometricOptimizers.𝔄! takes the same reduction with the column sums written into its scratch, and uses the value only to pick the number of halvings s = ⌈log₂(‖X‖₁/θ)⌉. On a real X that value is opnorm₁'s to the bit; on a complex X the two can differ in the last bit.
opnorm₁ and opnorm1 agree to a few eps, not bitwise: opnorm1 accumulates each column sequentially in at least Float64, whereas sum is pairwise and accumulates in eltype(X). So a difference of an ulp can at most shift s by one, and only for an argument that lands exactly on a power of two.
GeometricOptimizers.𝔄! — Method
𝔄!(ws, X, algorithm)GeometricOptimizers.𝔄(X, algorithm) written into ws.𝔄X, and returned, with the scratch of the RetractionWorkspace ws in place of fresh temporaries.
X is $2n\times{}2n$ for the $n$ that ws was built for, and is not one of the buffers the algorithm writes; ws.X is the buffer meant for it. ws holds the scratch of algorithm if it was built for Geodesic(algorithm) or for no retraction. Every step and every product is the one the allocating method takes, in the same order, so the two agree bit for bit.
ScaledSquaring, NativePade and TaylorSeries then allocate nothing, with mul! and broadcasts only, so no scalar indexing either. AugmentedPade writes X into the $4n\times{}4n$ ws.augmented, whose identity and zero blocks were written when ws was built, and calls Base.exp on it: it allocates what that exp allocates, and nothing besides. Any other algorithm falls back to the allocating 𝔄 and copies the answer in.
GeometricOptimizers.𝔄 — Method
𝔄(B̂, B̄)
𝔄(B̂, B̄, algorithm)Compute $\mathfrak{A}(B', B'') := \sum_{n=1}^\infty \frac{1}{n!} ((B'')^TB')^{n-1}.$
This expression has the property $\mathbb{I} + B'\mathfrak{A}(B', B'')(B'')^T = \exp(B'(B'')^T).$
Note that the argument $(B'')^TB'$ is only $2n\times{}2n$, so this is where the cost of a retraction is set by $n$ rather than by $N$.
Examples
using GeometricOptimizers
using GeometricOptimizers: 𝔄
import Random
Random.seed!(123)
B = rand(StiefelLieAlgHorMatrix, 10, 2)
B̂ = hcat(vcat(.5 * B.A, B.B), vcat(one(B.A), zero(B.B)))
B̄ = hcat(vcat(one(B.A), zero(B.B)), vcat(-.5 * B.A, -B.B))
one(B̂ * B̄') + B̂ * 𝔄(B̂, B̄) * B̄' ≈ exp(Matrix(B))
# output
trueGeometricOptimizers.𝔄 — Method
𝔄(X, algorithm)Compute $\mathfrak{A}(X)$ with the requested AbstractExponentialAlgorithm.
All algorithms compute the same function and differ only in accuracy at a large X, in cost, and in which backends they run on. See AbstractExponentialAlgorithm for the comparison and ScaledSquaring, which is the default.
Examples
The five agree wherever the unscaled series is still accurate, and only four of them agree beyond that:
using GeometricOptimizers
using GeometricOptimizers: 𝔄, ScaledSquaring, NativePade, AugmentedPade, TaylorSeries
import Random
Random.seed!(123)
X = randn(6, 6)
isapprox(𝔄(X, ScaledSquaring()), 𝔄(X, NativePade()); rtol = 1e-12) &&
isapprox(𝔄(X, NativePade()), 𝔄(X, AugmentedPade()); rtol = 1e-12) &&
isapprox(𝔄(X, ScaledSquaring()), 𝔄(X, TaylorSeries()); rtol = 1e-12)
# output
trueGeometricOptimizers.𝔄 — Method
𝔄(A)Compute $\mathfrak{A}(A) := \sum_{n=1}^\infty \frac{1}{n!} (A)^{n-1}.$
Implementation
The partial sum is accumulated term by term, each term obtained from its predecessor by $A^{n-1}/n! = (A^{n-2}/(n-1)!)\cdot{}A/n$; the sum stops when the norm of a term falls below machine precision. Both start at the identity, which is the $n = 1$ term. The recurrence and the accumulation are in place, so the loop allocates nothing.
The series converges for every A, but cancellation can make direct summation inaccurate for $\|A\| \gg 1$ — see TaylorSeries for what it does at a large argument. This method is therefore intended as a small-argument kernel. It is used by ScaledSquaring only after the argument has been divided to a norm below θ. Reach for it directly only if you know the argument is small.
GeometricOptimizers.AbstractRetraction — Type
AbstractRetractionSupertype of the retractions, i.e. of the maps that turn an element of a horizontal Lie algebra back into a point of the manifold.
A retraction is how every step in this package is taken: an OptimizerMethod produces a direction $B$ in the horizontal component of $\mathfrak{g}$, and $\Lambda \mapsto \Lambda\cdot\mathrm{retract}(B)$ moves the global section — and with it the point — without ever leaving the manifold. An instance is passed to Optimizer as retraction = Cayley(); the default is Cayley.
Concrete subtypes are Geodesic and Cayley. A new one has to supply retraction(::NewRetraction, x); the callable form R(x) and everything in update_section! then follow.
For every manifold layer one has to specify a retraction that takes the layer and elements of the (global) tangent space.
GeometricOptimizers.Cayley — Type
Cayley <: AbstractRetractionThe Cayley transform as a retraction, and the default one.
\[\mathrm{Cayley}(B) = \left(\mathbb{I} - \frac{1}{2}B\right)^{-1}\left(\mathbb{I} + \frac{1}{2}B\right)\]
For $B$ in the horizontal component this maps into the Lie group, so the retracted point stays on the manifold to round-off. cayley never forms the $N\times{}N$ inverse: it factors $B = B'(B'')^T$ into two $N\times{}2n$ matrices with lift_factors and inverts a $2n\times{}2n$ matrix instead.
cayley and geodesic assemble the $N\times{}N$ result the same way, as $\mathbb{I} + B'C(B'')^T$ from the two $N\times{}2n$ factors of lift_factors, so both are $O(N^2n)$. They differ only in the $2n\times{}2n$ matrix $C$: an inverse for Cayley, $\mathfrak{A}(X)$ for Geodesic. In the measurements of What they cost, from $N = 10$ to $N = 1000$, Cayley is the faster of the two at every size and with every algorithm. Timings are machine-dependent. Choose between the two by the map the algorithm needs; Cayley is unconditionally stable and needs no matrix function at all.
Examples
using GeometricOptimizers
using GeometricOptimizers: Cayley, check
Y = rand(StiefelManifold, 5, 3)
B = GeometricOptimizers.global_rep(GlobalSection(Y), rand(5, 3))
check(Cayley()(B)) < 1e-14 # the retracted element is still on the manifold
# output
true$\alpha \mapsto \mathrm{Cayley}(\alpha{}B)$ is not a one-parameter subgroup — only Geodesic is. It agrees with the geodesic to first order at $\alpha = 0$ and departs from it as the step grows, so the generator of the curve's velocity turns with $\alpha$ instead of staying $B$. retraction_differential is what supplies it, and with it trial_slope is the exact derivative of a line search's merit under either retraction. A slope paired against $B$ would be only a first-order approximation under Cayley.
See cayley for the implementation and Geodesic for the alternative.
GeometricOptimizers.Geodesic — Type
Geodesic(algorithm = ScaledSquaring()) <: AbstractRetractionThe exponential map as a retraction, i.e. the true geodesic of the manifold.
\[\mathrm{Geodesic}(B) = \exp(B)\]
Because this is the matrix exponential, $\alpha \mapsto \mathrm{Geodesic}(\alpha{}B)$ is a one-parameter subgroup: it follows the geodesic through the point in the direction $B$ exactly, and $\mathrm{Geodesic}((\alpha+\beta)B) = \mathrm{Geodesic}(\alpha{}B)\mathrm{Geodesic}(\beta{}B)$. That is the property Cayley lacks, and the reason a derivative-based line search is exact here.
geodesic exploits the sparsity of a horizontal lift rather than exponentiating the full $N\times{}N$ matrix: the only matrix function it evaluates is on a $2n\times{}2n$ argument. cayley is built the same way, so the two cost the same order, $O(N^2n)$; see the note on Cayley for the measured difference.
algorithm selects how the exponential is evaluated. All of them compute the same map — the choice is one of accuracy at a large lift, cost, and backend support — and the default ScaledSquaring is the one to use unless there is a reason not to. See AbstractExponentialAlgorithm for the comparison.
Examples
using GeometricOptimizers
using GeometricOptimizers: Geodesic, check
Y = rand(StiefelManifold, 5, 3)
B = GeometricOptimizers.global_rep(GlobalSection(Y), rand(5, 3))
check(Geodesic()(B)) < 1e-14 # the retracted element is still on the manifold
# output
trueA large lift is where the algorithms part company, and the reason the default is what it is:
using GeometricOptimizers
using GeometricOptimizers: Geodesic, ScaledSquaring, TaylorSeries, check
import Random
Random.seed!(1234)
B = 60 * rand(StiefelLieAlgHorMatrix, 20, 3) # ‖B̄‖ ≈ 393
check(Geodesic()(B)) < 1e-12, check(Geodesic(TaylorSeries())(B)) < 1e-12
# output
(true, false)See geodesic for the implementation and Cayley for the rational alternative, and Exponential Algorithms for the choice of algorithm.
GeometricOptimizers.cayley — Method
cayley(A::AbstractVecOrMat)Return A unchanged. This is the identity by design, not a missing Cayley transform.
A plain vector or matrix is a parameter in a vector space, and the retraction there is the Euclidean one, $x \mapsto x + A$. That addition happens in update_section!, so the retraction applied to the direction has nothing left to do. geodesic on a plain array is the identity for the same reason. On a horizontal lift, cayley is the Cayley transform.
GeometricOptimizers.cayley — Method
cayley(B̄::GrassmannLieAlgHorMatrix)Compute the Cayley retraction of B.
This is equivalent to the method of cayley for StiefelLieAlgHorMatrix.
GeometricOptimizers.cayley — Method
cayley(B̄::StiefelLieAlgHorMatrix)Compute the Cayley retraction of B.
Implementation
Internally this is using
\[\mathrm{Cayley}(\bar{B}) = \mathbb{I} + B' \left(\mathbb{I}_{2n} - \frac{1}{2} (B'')^T B'\right)^{-1} (B'')^T,\]
with
\[\bar{B} = \begin{bmatrix} A & -B^T \\ B & \mathbb{O} \end{bmatrix} = \begin{bmatrix} \frac{1}{2}A & \mathbb{I} \\ B & \mathbb{O} \end{bmatrix} \begin{bmatrix} \mathbb{I} & \mathbb{O} \\ \frac{1}{2}A & -B^T \end{bmatrix} =: B'(B'')^T,\]
i.e. $\bar{B}$ is expressed as a product of two $N\times{}2n$ matrices.
This is the same shape geodesic(::AbstractLieAlgHorMatrix) has, and for the same reason: the only matrix function either evaluates is on the $2n\times{}2n$ product $(B'')^TB'$. Getting there from the definition $\mathrm{Cayley}(\bar{B}) = (\mathbb{I} - \frac{1}{2}\bar{B})^{-1}(\mathbb{I} + \frac{1}{2}\bar{B})$ takes two steps. Write $C$ for the $2n\times{}2n$ inverse above. Splitting $\mathbb{I} + \frac{1}{2}\bar{B} = (\mathbb{I} - \frac{1}{2}\bar{B}) + \bar{B}$ gives $\mathrm{Cayley}(\bar{B}) = \mathbb{I} + (\mathbb{I} - \frac{1}{2}\bar{B})^{-1}\bar{B}$, and the Woodbury identity turns the remaining inverse into $(\mathbb{I} - \frac{1}{2}\bar{B})^{-1} = \mathbb{I} + \frac{1}{2}B'C(B'')^T$. The factor that leaves on the $2n\times{}2n$ side is then $\mathbb{I}_{2n} + \frac{1}{2}C(B'')^TB'$, which is $C$ itself, because $C$ inverts $\mathbb{I}_{2n} - \frac{1}{2}(B'')^TB'$.
The result is the $N\times{}N$ retraction of the lift, so the cost cannot fall below $O(N^2n)$, and this grouping reaches that floor: nothing larger than $N\times{}2n$ enters a product. Multiplying the factored left-hand side by an unfactored $\mathbb{I} + \frac{1}{2}\bar{B}$ instead multiplies two dense $N\times{}N$ matrices, which is $O(N^3)$ on its own and puts the retraction above geodesic at every size. scripts/cayley_regrouping_cost.jl carries the measurement.
Both sums are written as the five-argument mul! into an identity rather than as 𝕀 + X: the identity has to be built either way, and adding into it is what makes the product's own destination the answer instead of a temporary. scripts/retraction_step_allocations.jl carries that measurement. The $2n\times{}2n$ inverse stays an inv and is the allocation this cannot remove — lu! and rdiv! would take it in place on the host, and neither is something a KernelAbstractions backend is obliged to supply, where inv is what cayley already runs on Metal through.
GeometricOptimizers.cayley — Method
cayley(B̄::SymplecticLieAlgHorMatrix)Compute the Cayley retraction of B, by the method of cayley(::StiefelLieAlgHorMatrix).
The Cayley transform of a Hamiltonian matrix is symplectic, so the result preserves the Poisson tensor $\bar{\mathbb{J}}$ of the basis SymplecticLieAlgHorMatrix describes.
GeometricOptimizers.cayley — Method
cayley(Y::Manifold, Δ)Take as input an element of a manifold Y and a tangent vector in Δ in the corresponding tangent space and compute the Cayley retraction.
In different notation: take as input an element $x$ of $\mathcal{M}$ and an element of $T_x\mathcal{M}$ and return $\mathrm{Cayley}(v_x).$
Examples
using GeometricOptimizers
Y = StiefelManifold([1. 0. 0.;]' |> Matrix)
Δ = [0. .5 0.;]' |> Matrix
Y₂ = GeometricOptimizers.cayley(Y, Δ)
Y₂' * Y₂ ≈ [1.;]
# output
trueSee the example in geodesic(::Manifold, ::AbstractMatrix).
GeometricOptimizers.geodesic — Function
geodesic(B̄::AbstractLieAlgHorMatrix, algorithm = ScaledSquaring())Compute the geodesic of a horizontal lift, i.e. $\exp(\bar{B})$.
Works for both StiefelLieAlgHorMatrix and GrassmannLieAlgHorMatrix — manifold_type supplies the manifold the result belongs to.
Implementation
Internally this is using
\[\exp(\bar{B}) = \mathbb{I} + B'\mathfrak{A}(B', B'')(B'')^T,\]
with $\bar{B} = B'(B'')^T$ the factorisation of lift_factors. The only matrix function this evaluates is $\mathfrak{A}$ on the $2n\times{}2n$ product $(B'')^TB'$, so the cost is set by $n$ and not by $N$, and so is the accuracy — see AbstractExponentialAlgorithm for the choice of algorithm and GeometricOptimizers.𝔄 for the implementations. The default ScaledSquaring is accurate at every lift norm.
GeometricOptimizers.geodesic — Method
geodesic(Y::Manifold, Δ, algorithm = ScaledSquaring())Take as input an element of a manifold Y and a tangent vector in Δ in the corresponding tangent space and compute the geodesic (exponential map).
In different notation: take as input an element $x$ of $\mathcal{M}$ and an element of $T_x\mathcal{M}$ and return $\mathtt{geodesic}(x, v_x) = \exp(v_x).$
algorithm selects how the exponential is evaluated and is passed straight through to geodesic(::AbstractLieAlgHorMatrix); see AbstractExponentialAlgorithm for the choice. It matters only for a large $\Delta$ — the default ScaledSquaring is accurate at every step size.
Examples
using GeometricOptimizers
Y = StiefelManifold([1. 0. 0.;]' |> Matrix)
Δ = [0. .5 0.;]' |> Matrix
Y₂ = GeometricOptimizers.geodesic(Y, Δ)
Y₂' * Y₂ ≈ [1.;]
# output
trueImplementation
Internally this geodesic method calls geodesic(::AbstractLieAlgHorMatrix).
GeometricOptimizers.lift_factors — Method
lift_factors(B::AbstractLieAlgHorMatrix)Factor a horizontal lift into the two $N\times{}2n$ matrices $B'$ and $B''$ with $\bar{B} = B'(B'')^T$:
\[\bar{B} = \begin{bmatrix} A & -B^T \\ B & \mathbb{O} \end{bmatrix} = \begin{bmatrix} \frac{1}{2}A & \mathbb{I} \\ B & \mathbb{O} \end{bmatrix} \begin{bmatrix} \mathbb{I} & \mathbb{O} \\ \frac{1}{2}A & -B^T \end{bmatrix} =: B'(B'')^T.\]
Every retraction in this package is built on this factorisation — it is what makes their cost scale with $n$ rather than with $N$, since the only matrix function either of them evaluates is on the $2n\times{}2n$ product $(B'')^TB'$. Both geodesic and cayley use it, for every manifold.
For a GrassmannLieAlgHorMatrix this is the same expression with $A \equiv \mathbb{O}$. For a SymplecticLieAlgHorMatrix it is the same expression with the Hamiltonian block $\mathcal{A}$ for $A$ and the symplectic adjoint $\mathcal{B}^+$ for $B^T$, and for a BiorthogonalLieAlgHorMatrix the same expression with its block $C$ for $-B^T$.
Implementation
Both factors are allocated once, zeroed, and written block by block, rather than assembled out of nested vcats and hcats. The blocks are the same ones the formula above names; what goes is the chain of intermediate matrices each nesting level materialised — a vcat of two blocks, then an hcat of two of those, per factor, per call. The two zero blocks are then never written at all. This is on the per-iteration path: an optimizer step applies a retraction once per line-search trial and three times besides, and each of those calls this.
$(B'')^T$ is the matrix that is built, and $B''$ is returned as its adjoint, because every caller — cayley, geodesic, retraction_differential — consumes it as $(B'')^T$ and the two cancel exactly.
GeometricOptimizers.lift_from_columns — Method
lift_from_columns(B, V)Rebuild a lift of the same type as B from the $N\times{}n$ block V, i.e. from the first $n$ columns of a skew matrix, or of a Hamiltonian one for a SymplecticLieAlgHorMatrix. Used by retraction_differential, which is the only place a lift has to be assembled from its action on $E$ rather than from its own blocks.
Not to be confused with the canonical horizontal lift GeometricOptimizers.Ω, which maps a tangent vector to an element of $\mathfrak{g}^\mathrm{hor}$. This one takes the columns of a matrix that is already in the Lie algebra.
GeometricOptimizers.retraction — Method
retraction(R::AbstractRetraction, x)Apply the retraction R to x, i.e. dispatch on the retraction type rather than calling geodesic or cayley by name.
This is what a caller who has been handed a retraction = … keyword uses: the two shipped types, Geodesic and Cayley, select the two functions, and a Geodesic also carries the AbstractExponentialAlgorithm its geodesic is evaluated with. R(x) is the same thing written as a call.
x is an AbstractLieAlgHorMatrix on a manifold — the retractions this package is about map $\mathfrak{g}^\mathrm{hor}\to{}G$ — a NamedTuple of parameters, or an ordinary array, on which every retraction is the identity because the extended retraction on a vector space is addition and update_section! does the adding.
An R and an x that do not go together is an error that says so, rather than a nothing that fails further downstream.
GeometricOptimizers.retraction_differential! — Method
retraction_differential!(D, workspace, retraction, B, α)retraction_differential(retraction, B, α) written into D, which has B's type and shape, and returned.
workspace is the RetractionWorkspace of B's point, the tree of them a parameter set has, or nothing. A Cayley lift at $\alpha \neq 0$ with a workspace on a host Matrix of a LAPACK element type, Float32, Float64 or their complex types, is evaluated in that workspace and allocates nothing: its two solves are LAPACK.getrf! and LAPACK.getrs! on workspace buffers, which are the two calls \ makes, so the answer is the allocating method's to the bit. A BiorthogonalLieAlgHorMatrix is the exception: it takes the allocating method. Every other case copies the allocating method's answer into D — at $\alpha = 0$, under Geodesic and for an ordinary array that is a copy of B — including a workspace on any other array type, where \ stays.
GeometricOptimizers.retraction_differential — Method
retraction_differential(retraction, B, α)The horizontal lift $D(\alpha)$ that generates the velocity of the curve a line search walks along.
trial_iterate! builds its trial point as $x(\alpha) = \Lambda_0\mathrm{retract}(\alpha\bar{B})E$ with $\Lambda_0$ the section the step starts from, so with $W(\alpha) = \Lambda_0\mathrm{retract}(\alpha\bar{B})$ the frame the cache holds afterwards, this returns the $D(\alpha)$ for which
\[\frac{dx}{d\alpha} = W(\alpha)D(\alpha)E .\]
trial_slope pairs the gradient against it, which is what makes $\varphi'(\alpha)$ the derivative of $\varphi$.
Implementation
For Geodesic this is $\bar{B}$ itself. The exponential is a one-parameter subgroup, so $\frac{d}{d\alpha}\exp(\alpha\bar{B}) = \exp(\alpha\bar{B})\bar{B}$ and the frame factors out whole. The same holds for an ordinary array under either retraction, where the retraction is addition and $\varphi$ is affine in $\alpha$.
Cayley is not a one-parameter subgroup, and this is what that costs. With $M = (\mathbb{I} - \frac{\alpha}{2}\bar{B})^{-1}$,
\[\frac{d}{d\alpha}\mathrm{Cayley}(\alpha\bar{B}) = M\bar{B}M , \qquad D(\alpha) = \mathrm{Cayley}(\alpha\bar{B})^{-1}M\bar{B}M = M^T\bar{B}M ,\]
using $M^T = (\mathbb{I} + \frac{\alpha}{2}\bar{B})^{-1}$ for skew $\bar{B}$. For a SymplecticLieAlgHorMatrix, which is Hamiltonian rather than skew, the same derivation gives $D(\alpha) = (\mathbb{I} + \frac{\alpha}{2}\bar{B})^{-1}\bar{B}M$, which is the expression evaluated below for every lift. $D$ is in the Lie algebra, skew or Hamiltonian, but not horizontal; for these lifts only its first $n$ columns ever enter — $D(\alpha)E$ — and the horizontal projection has the same ones, so what lift_from_columns is handed is that projection. A BiorthogonalLieAlgHorMatrix needs the first $n$ rows as well, and has a method of its own.
For a GrassmannLieAlgHorMatrix the top $n\times{}n$ block is dropped rather than kept, and that is not an approximation. $M$, $M^T$ and $\bar{B}$ are all rational functions of $\bar{B}$ and so commute, which gives
\[D(\alpha) = \bar{B}\left(\mathbb{I} - \tfrac{\alpha^2}{4}\bar{B}^2\right)^{-1} ,\]
and for a Grassmann lift — where $A \equiv \mathbb{O}$, so $\bar{B}^2$ is block-diagonal — the top-left block of that product is identically zero at every $\alpha$. The drop is exact whatever $D$ is paired against, not merely exact against a gradient that happens to be orthogonal to $Y$.
Both inverses are taken through lift_factors and the Woodbury identity, exactly as cayley does, so the cost is $O(Nn^2 + n^3)$ and no $N\times{}N$ matrix is formed.
α = 0 returns B unchanged, and that is the case that matters for cost: SimpleSolvers.Backtracking — the default of default_linesearch — evaluates $\varphi'$ only at $\alpha = 0$, so it never reaches the general branch.
GeometricOptimizers.NoWorkspace — Type
NoWorkspace()What GeometricOptimizers.retraction_workspace returns where there is no manifold to retract on.
The vector-space methods of update_section! take a workspace argument and ignore it — the extended retraction on a vector space is addition, which allocates nothing to begin with — so this type is a marker and has no method of its own. It exists only because nothing cannot serve as that marker.
Implementation
nothing is the obvious spelling and is the one thing this may not be. A parameter set's workspace is a tree walked in lockstep with its section tree, and NeuralNetworkParameters.mapparameters! reads a nothing in that position as skip this leaf: the leaf function is then never called, so the section is never transported and the iterate never moves. That is silent — the solve runs to its iteration limit and reports the point it started from. A singleton says the same thing and is an ordinary value to the walk.
(That name in plain code and not an @extref, for the reason iterative_hessians.jl gives about the same choice: an @extref that the published inventory does not carry is a build error rather than a dead link, and mapparameters! is not one of the names this package already links.)
GeometricOptimizers.RetractionWorkspace — Type
RetractionWorkspace(x::Manifold, retraction = nothing)
RetractionWorkspace(backend, T, N, n, retraction = nothing)The buffers update_section! retracts a horizontal lift into, held for the life of an Optimizer rather than rebuilt per call.
Every array a retraction of an $N\times{}n$ point needs is a fixed shape once $N$ and $n$ are known — the two factors of lift_factors, the $2n\times{}2n$ matrix the inverse is taken of, the $N\times{}N$ result, and the frame the result is transported into. An optimizer step applies a retraction once per line-search trial and three times besides, so those shapes are rebuilt six to fifteen times an iteration for a step that changes none of them.
Implementation
The four blocks that do not depend on the lift are written once, here, and never again: the two $n\times{}n$ identity blocks of $B'$ and $(B'')^T$, and the zero blocks beside them. lift_factors! then writes only the four that do. 𝕀_small2 and 𝕀_big are kept because both sums are formed as a five-argument mul! into an identity, which needs the identity to copy from.
The element type and the backend come from the point, so a workspace is on the same backend as the solve it belongs to and no method here names either.
The workspace also holds the scratch of GeometricOptimizers.𝔄!, which a geodesic step evaluates its $\mathfrak{A}$ with, and of retraction_differential!, as much of it as retraction reads: the 𝔄! scratch of its algorithm for a Geodesic, and that of the differential for Cayley on a host Matrix of a LAPACK element type. Every other scratch array is 0 × 0, so the type of a workspace does not depend on its retraction. A workspace built for one retraction serves that retraction only; one built with retraction = nothing holds all the scratch and serves every retraction. Optimizer builds its workspace for its own retraction.
In a workspace, the $\mathfrak{A}$ of ScaledSquaring and NativePade allocates nothing, and that of AugmentedPade allocates what Base.exp of its $4n\times{}4n$ matrix allocates. So in both precisions the two native algorithms are the lighter, and AugmentedPade the heavier by exactly its exp. scripts/in_place_retraction_cost.jl measures the figures.
What this does not remove: the $2n\times{}2n$ inv in cayley and the exp of AugmentedPade. Neither grows with $N$. inv stays an inv because lu! and rdiv! would take it in place on the host only, and a KernelAbstractions backend is under no obligation to supply either — inv is what cayley already runs on Metal through. ProjectedSkew takes its allocating geodesic and copies the answer in.
A solve whose parameters are not on a manifold has no workspace: see GeometricOptimizers.retraction_workspace.
GeometricOptimizers.lift_factors! — Method
lift_factors!(ws::RetractionWorkspace, B::AbstractLieAlgHorMatrix)lift_factors written into ws, returning nothing.
Only the lift-dependent blocks are written — four for a Stiefel, a symplectic or a biorthogonal lift and two for a Grassmann one, whose $A$ block is identically zero. The identity and zero blocks were written when the workspace was built. ws has to have been built for B's shape.
GeometricOptimizers.retraction_matrix! — Method
retraction_matrix!(ws::RetractionWorkspace, R::AbstractRetraction, B::AbstractLieAlgHorMatrix)The $N\times{}N$ matrix retraction(R, B) wraps in a manifold type, written into ws.retracted and returned bare.
The matrix and not the manifold: update_section! reads the blocks of the result and discards the wrapper, so wrapping it would be one allocation per line-search trial for a value nothing keeps.
An AbstractRetraction this package does not ship has no in-place form here and falls through to the allocating retraction, with the answer copied in. A workspace never changes what a retraction means. A bare callable is not covered — update_section! accepts one as its retraction, and src/utils.jl passes one, but only ever together with no workspace, so there is no retraction type left here to dispatch on and a caller who pairs the two gets a MethodError rather than a silent fallback.
ws has to have been built for B's shape, as for lift_factors!, and every arm asserts it. The assertion is not decoration: the fallback arms reach ws.retracted through copyto!, and copyto! into an oversized destination copies linearly rather than throwing, so a workspace of the wrong shape would scramble the layout of the answer instead of rejecting it.
GeometricOptimizers.retraction_workspace — Function
retraction_workspace(x, retraction = nothing)
retraction_workspace(opt::Optimizer)The RetractionWorkspace a solve over x with retraction needs, or NoWorkspace where x carries no manifold. On an Optimizer it is the accessor instead, returning the workspace that optimizer was built with.
Optimizer builds one of these for its retraction at construction and hands it to every update_section! on the step path. A parameter set gets a tree of them in the shape its section tree has, a NoWorkspace at every leaf that is an ordinary array — the extended retraction on a vector space is addition, which allocates nothing to begin with.
The two meanings share a name and cannot collide: Optimizer is not a member of OptimizerSolution, which is what the building methods dispatch on.
GeometricOptimizers.DirectCayleyWorkspace — Type
DirectCayleyWorkspace(Y::StiefelManifold)The buffers of cayley_direct! and transport! at a point of the shape of Y.
For $Y \in St(k, M)$ it holds four $M\times{}2k$ matrices, one $M\times{}k$ matrix, two $k\times{}k$ matrices, two $2k\times{}2k$ matrices and three $2k\times{}k$ matrices, all on the backend of Y.A: $O(Mk + k^2)$ storage and no $M\times{}M$ array. A workspace serves every point of its shape and element type.
GeometricOptimizers.cayley_direct! — Method
cayley_direct!(Y_new::StiefelManifold, Y::StiefelManifold, Δ::AbstractMatrix, ws::DirectCayleyWorkspace)Write the Cayley retraction of the tangent vector Δ at Y into Y_new, and return Y_new.
The retraction is $(\mathbb{I}_M - \frac{1}{2}W)^{-1}(\mathbb{I}_M + \frac{1}{2}W)Y$ with the generator $W = \Delta{}Y^T - Y\Delta^T + Y\Delta^TYY^T$. It is computed without an $M\times{}M$ matrix and without the orthogonal complement of Y, through the rank-$2k$ factorization $W = UV$ with
\[A = \frac{1}{2}(Y^T\Delta - \Delta^TY), \quad K = \Delta - Y(Y^T\Delta), \quad U = [Y\;\; K], \quad V = \begin{bmatrix} AY^T - K^T \\ Y^T \end{bmatrix},\]
and the Sherman–Morrison–Woodbury identity
\[Y_\mathrm{new} = Y + U M_{2k}^{-1} VY, \qquad M_{2k} = \mathbb{I}_{2k} - \frac{1}{2}VU.\]
The cost is $O(Mk^2)$, and the only solve is the $2k\times{}2k$ system $M_{2k}$. That solve is an in-place LinearAlgebra.lu!, so the retraction runs only on a backend that supplies one; on JLArrays it raises a scalar-indexing error. For a Δ off the tangent space the result is the retraction of its tangent projection $\Delta - \frac{1}{2}Y(Y^T\Delta + \Delta^TY)$.
Y_new may be Y: the result is written into ws first and copied into Y_new.A last. A Δ, Y_new or ws of another size than Y raises a DimensionMismatch before anything is written.
GeometricOptimizers.cayley_direct — Method
cayley_direct(Y::StiefelManifold, Δ::AbstractMatrix)The Cayley retraction of the tangent vector Δ at Y, as a new StiefelManifold. See cayley_direct!.
GeometricOptimizers.AbstractVectorTransport — Type
AbstractVectorTransportA vector transport on the Stiefel manifold: it moves a vector $\Xi$ at $Y$ to the tangent space at $Y_\mathrm{new}$, the Cayley retraction of a step $\Delta$ at $Y$. See transport!, ProjectionTransport and DifferentiatedCayleyTransport.
GeometricOptimizers.DifferentiatedCayleyTransport — Type
DifferentiatedCayleyTransport <: AbstractVectorTransportThe differential of the Cayley retraction at $\Delta$ in the direction $\Xi$:
\[\mathcal{T}_\Delta(\Xi) = (\mathbb{I}_M - \tfrac{1}{2}W(\Delta))^{-1} W(P_Y\Xi) (\mathbb{I}_M - \tfrac{1}{2}W(\Delta))^{-1} Y, \qquad P_Y\Xi = \Xi - \tfrac{1}{2}Y(Y^T\Xi + \Xi^TY),\]
with $W$ the generator of cayley_direct!. It is $\frac{\mathrm{d}}{\mathrm{d}s}\big|_{s=0}\mathtt{cayley\_direct}(Y, \Delta + s\Xi)$. Any $\Xi$ is accepted, and its part off the tangent space at $Y$ is dropped; at $\Delta = 0$ the result is $P_Y\Xi$.
It is computed in $O(Mk^2)$, with the matrix $M_{2k}$ of the retraction and the factors $U_\Xi V_\Xi = W(P_Y\Xi)$, as
\[\bigl(U_\Xi + \tfrac{1}{2}UM_{2k}^{-1}(VU_\Xi)\bigr)(V_\Xi W_+), \qquad W_+ = (\mathbb{I}_M - \tfrac{1}{2}W(\Delta))^{-1}Y = Y + \tfrac{1}{2}UM_{2k}^{-1}VY.\]
$W_+$ comes from the factorization of the step, so the result does not read the entries of $Y_\mathrm{new}$. Its solve is the lu! of cayley_direct!, with the same backend limit.
GeometricOptimizers.ProjectionTransport — Type
ProjectionTransport <: AbstractVectorTransportThe transport by orthogonal projection onto the tangent space at $Y_\mathrm{new}$:
\[\Xi_\mathrm{out} = \Xi - \frac{1}{2}Y_\mathrm{new}(Y_\mathrm{new}^T\Xi + \Xi^TY_\mathrm{new}).\]
It reads neither $Y$ nor $\Delta$.
GeometricOptimizers.transport! — Method
transport!(Ξ_out, Y_new::StiefelManifold, Y::StiefelManifold, Δ, Ξ, tr::AbstractVectorTransport, ws::DirectCayleyWorkspace)Write the transport tr of Ξ from Y to Y_new = cayley_direct(Y, Δ) into Ξ_out, and return Ξ_out. Ξ_out may be Ξ, and must not be Y_new.A. A Ξ_out, Y_new, Δ, Ξ or ws of another size than Y raises a DimensionMismatch before anything is written.
GeometricOptimizers.transport — Method
transport(Y_new::StiefelManifold, Y::StiefelManifold, Δ, Ξ, tr::AbstractVectorTransport)The transport tr of Ξ from Y to Y_new = cayley_direct(Y, Δ), in a new matrix of the array type of Y.A. See transport!.
GeometricOptimizers.cayley — Method
cayley(B̄::BiorthogonalLieAlgHorMatrix)The Cayley retraction of a biorthogonal lift, as the pair $[\mathrm{Cayley}(\bar{B})\ \ \mathrm{Cayley}(\bar{B})^{-T}]$, i.e. as a BiorthogonalManifold of $N\times2N$ matrices.
Both factors are taken by the method of cayley(::StiefelLieAlgHorMatrix), the second through $\mathrm{Cayley}(\bar{B})^{-1} = \mathrm{Cayley}(-\bar{B})$. $\mathrm{Cayley}(\bar{B})$ is invertible wherever $\mathbb{I} - \frac{1}{2}\bar{B}$ and $\mathbb{I} + \frac{1}{2}\bar{B}$ are, which for a lift that is not skew-symmetric is not every lift: an eigenvalue $\pm2$ of $\bar{B}$ makes the $2n\times2n$ matrix the method inverts singular.
GeometricOptimizers.geodesic — Function
geodesic(B̄::BiorthogonalLieAlgHorMatrix, algorithm = ScaledSquaring())The group exponential of a biorthogonal lift, as the pair $[\exp(\bar{B})\ \ \exp(\bar{B})^{-T}]$, i.e. as a BiorthogonalManifold of $N\times2N$ matrices.
$\exp(\bar{B})^{-T} = \exp(-\bar{B})^T$, and both exponentials are taken by geodesic(::AbstractLieAlgHorMatrix)'s method. The curve $t\mapsto\lambda(Y)\exp(t\bar{B})\cdot(E, E)$ is the orbit of a one-parameter subgroup and not a geodesic of the metric(::BiorthogonalManifold, ::AbstractMatrix, ::AbstractMatrix) of the manifold, which no group element preserves; the name is kept because it is what Geodesic selects for every manifold.
GeometricOptimizers.retraction_differential — Method
retraction_differential(::Cayley, B̄::BiorthogonalLieAlgHorMatrix, α)retraction_differential for a biorthogonal lift. $D(\alpha) = (\mathbb{I} + \frac{\alpha}{2}\bar{B})^{-1}\bar{B}(\mathbb{I} - \frac{\alpha}{2}\bar{B})^{-1}$ as for every lift, but its horizontal part is not determined by its first $n$ columns alone: the action of $D\in\mathfrak{gl}(N)$ on $(E, E)$ is $(DE, -D^TE)$, and the vertical space is the lower right block. So the first $n$ columns give $A$ and $B$, and the first $n$ rows, which are the first $n$ columns of $D^T = (\mathbb{I} - \frac{\alpha}{2}\bar{B}^T)^{-1}\bar{B}^T(\mathbb{I} + \frac{\alpha}{2}\bar{B}^T)^{-1}$, give $C$. Both are taken through lift_factors, the second with the two factors exchanged and $\alpha$ negated.