Special Matrices API
The structured matrices, and the horizontal components of the Lie algebras that serve as global tangent spaces.
GeometricOptimizers.SkewSymMatrix — Type
SkewSymMatrix(S::AbstractVector, n::Integer)Instantiate a skew-symmetric matrix with information stored in vector S.
A skew-symmetric matrix $A$ is a matrix $A^T = -A$.
Internally the struct saves a vector $S$ of size $n(n-1)\div2$. The conversion is done the following way:
\[[A]_{ij} = \begin{cases} 0 & \text{if $i=j$} \\ S[( (i-2) (i-1) ) \div 2 + j] & \text{if $i>j$}\\ S[( (j-2) (j-1) ) \div 2 + i] & \text{else}. \end{cases}\]
So $S$ stores a string of vectors taken from $A$: $S = [\tilde{a}_1, \tilde{a}_2, \ldots, \tilde{a}_n]$ with $\tilde{a}_i = [[A]_{i1},[A]_{i2},\ldots,[A]_{i(i-1)}]$.
Also see SymmetricMatrix, StrictlyLowerTriangular and StrictlyUpperTriangular.
Examples
using GeometricOptimizers
S = [1, 2, 3, 4, 5, 6]
SkewSymMatrix(S, 4)
# output
4×4 SkewSymMatrix{Int64, Vector{Int64}}:
0 -1 -2 -4
1 0 -3 -5
2 3 0 -6
4 5 6 0GeometricOptimizers.SkewSymMatrix — Method
SkewSymMatrix(A::AbstractMatrix)Perform 0.5 * (A - transpose(A)) and store the matrix in an efficient way (as a vector with $n(n-1)/2$ entries).
If the constructor is called with a matrix as input it returns a skew-symmetric matrix via the projection:
\[A \mapsto \frac{1}{2}(A - A^T).\]
Examples
using GeometricOptimizers
M = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]
SkewSymMatrix(M)
# output
4×4 SkewSymMatrix{Float64, Vector{Float64}}:
0.0 -1.5 -3.0 -4.5
1.5 0.0 -1.5 -3.0
3.0 1.5 0.0 -1.5
4.5 3.0 1.5 0.0Extended help
Note that the constructor is designed in such a way that it always returns matrices of type SkewSymMatrix{<:AbstractFloat} when called with a matrix, even if this matrix is of type AbstractMatrix{<:Integer}.
If the user wishes to allocate a matrix SkewSymMatrix{<:Integer} then call:
SkewSymMatrix(::AbstractVector, n::Integer)Note that this is different from StrictlyLowerTriangular and StrictlyUpperTriangular as no projection takes place there.
GeometricOptimizers.SymmetricMatrix — Type
SymmetricMatrix(S::AbstractVector, n::Integer)Instantiate a symmetric matrix with information stored in vector S.
A SymmetricMatrix $A$ is a matrix $A^T = A$.
Internally the struct saves a vector $S$ of size $n(n+1)\div2$. The conversion is done the following way:
\[[A]_{ij} = \begin{cases} S[( (i-1) i ) \div 2 + j] & \text{if $i\geq{}j$}\\ S[( (j-1) j ) \div 2 + i] & \text{else}. \end{cases}\]
So $S$ stores a string of vectors taken from $A$: $S = [\tilde{a}_1, \tilde{a}_2, \ldots, \tilde{a}_n]$ with $\tilde{a}_i = [[A]_{i1},[A]_{i2},\ldots,[A]_{ii}]$.
Also see SkewSymMatrix, StrictlyLowerTriangular and StrictlyUpperTriangular.
Examples
using GeometricOptimizers
S = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
SymmetricMatrix(S, 4)
# output
4×4 SymmetricMatrix{Int64, Vector{Int64}}:
1 2 4 7
2 3 5 8
4 5 6 9
7 8 9 10GeometricOptimizers.SymmetricMatrix — Method
SymmetricMatrix(A::AbstractMatrix)Perform a projection and store the matrix in an efficient way (as a vector with $n(n+1)/2$ entries).
If the constructor is called with a matrix as input it returns a symmetric matrix via the projection:
\[A \mapsto \frac{1}{2}(A + A^T).\]
Examples
using GeometricOptimizers
M = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]
SymmetricMatrix(M)
# output
4×4 SymmetricMatrix{Float64, Vector{Float64}}:
1.0 3.5 6.0 8.5
3.5 6.0 8.5 11.0
6.0 8.5 11.0 13.5
8.5 11.0 13.5 16.0Extended help
Note that the constructor is designed in such a way that it always returns matrices of type SymmetricMatrix{<:AbstractFloat} when called with a matrix, even if this matrix is of type AbstractMatrix{<:Integer}.
If the user wishes to allocate a matrix SymmetricMatrix{<:Integer} then call
SymmetricMatrix(::AbstractVector, n::Integer)Note that this is different from StrictlyLowerTriangular and StrictlyUpperTriangular as no projection takes place there.
GeometricOptimizers.StiefelProjection — Type
StiefelProjection(backend, T, N, n)Make a matrix of the form $\begin{bmatrix} \mathbb{I} & \mathbb{O} \end{bmatrix}^T$ for a specific backend and data type.
An array that essentially does vcat(I(n), zeros(N-n, n)) with GPU support.
Extended help
For $N \geq n$ an instance of StiefelProjection should technically also belong to StiefelManifold: its columns are orthonormal.
Any other shape is the same matrix Matrix{T}(I, N, n): ones on the diagonal and zeros elsewhere. For $n > N$ that is $\begin{bmatrix} \mathbb{I} & \mathbb{O} \end{bmatrix}$, whose columns are not orthonormal, and a projection with no rows or no columns is the empty matrix of its size. The host and the backend constructors agree on every shape.
GeometricOptimizers.StiefelProjection — Method
StiefelProjection(A::AbstractMatrix)Extract necessary information from A and build an instance of StiefelProjection.
Necessary information here refers to the backend, the data type and the size of the matrix.
Base.:* — Method
*(E::StiefelProjection, A::AbstractMatrix)
*(A::AbstractMatrix, E::StiefelProjection)
*(E::StiefelProjection, b::AbstractVector)The product, taken on the wrapped array.
StiefelProjection holds its entries in an ordinary array, so unwrapping is all these do — for E and E' alike, and for +, -, mul! and a scalar product as well, with the same methods that a manifold point uses. Without them the product falls through to the generic AbstractMatrix path, which reaches getindex one entry at a time. That is scalar indexing, and it is what stops a retraction on a device: geodesic and cayley each take one product against the projection — expB * E and cayleyB * E — with E built from the horizontal lift and so carrying the point's own backend. Both operands are on the device, and only the wrapper puts the product on the host path.
Both operands have to be on one backend: a pair on two backends raises an ArgumentError naming both, rather than answering on whichever backend the argument order picks.
GeometricOptimizers.AbstractTriangular — Type
AbstractTriangularBase.:* — Method
*(A::AbstractTriangular, B::AbstractMatrix)The product, read off the packed storage vector by a kernel rather than through getindex.
Without this method the product falls through to the generic AbstractMatrix path, which asks A for one entry at a time. That is scalar indexing, so it cannot run on a device at all. The packed vector holds $n(n-1)/2$ entries and the generic path reads $n^2$ of them, the other $n(n+1)/2$ being zeros that StrictlyLowerTriangular and StrictlyUpperTriangular manufacture — but do not read a host speed-up into that, which is what the arithmetic invites. Against the path this method shadows, the ratio is not monotone in n, and at a small n both products are slower, because the kernel launch has a fixed cost that a small product cannot amortize. scripts/triangular_multiply_cost.jl is the check and CHANGELOG.md carries its table. The device is what this buys.
The kernel is the one each subtype supplies, and it is where the two differ: a lower-triangular row i runs over 1:(i-1) and an upper-triangular one over (i+1):n, reading the same packed vector through different index arithmetic.
*(::AbstractMatrix, ::AbstractTriangular) is written as (A' * B')'. For a real element type that goes through here as well, because adjoint on one of these is then a type swap onto the same storage. A complex one does not: the swap is bound to Real, for the reason the comment on adjoint(::StrictlyLowerTriangular) in upper_triangular.jl gives, and the lazy Adjoint it falls through to is not an AbstractTriangular. So that product stays on the generic path and stays host-only.
GeometricOptimizers.StrictlyLowerTriangular — Type
StrictlyLowerTriangular(S::AbstractVector, n::Int)Build a lower-triangular matrix from a vector.
A lower-triangular matrix is an $n\times{}n$ matrix that has zeros on the diagonal and on the upper triangular.
The data are stored in a vector $S$ similarly to other matrices. See StrictlyUpperTriangular, SkewSymMatrix and SymmetricMatrix.
The struct has two fields: S and n. The first stores all the entries of the matrix in a sparse fashion (in a vector) and the second is the dimension $n$ for $A\in\mathbb{R}^{n\times{}n}$.
adjoint (L') returns a StrictlyUpperTriangular built around the same storage vector, not a copy: parent(L') === parent(L) holds, so writing into the adjoint also writes into L. Reusing the storage transposes without conjugating, so this method is defined for a real element type only; a complex one falls through to LinearAlgebra's lazy Adjoint, which conjugates and does not alias.
Examples
using GeometricOptimizers
S = [1, 2, 3, 4, 5, 6]
StrictlyLowerTriangular(S, 4)
# output
4×4 StrictlyLowerTriangular{Int64, Vector{Int64}}:
0 0 0 0
1 0 0 0
2 3 0 0
4 5 6 0GeometricOptimizers.StrictlyLowerTriangular — Method
StrictlyLowerTriangular(A::AbstractMatrix)Build a lower-triangular matrix from a matrix.
This is done by taking the lower left of that matrix.
Examples
using GeometricOptimizers
M = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]
StrictlyLowerTriangular(M)
# output
4×4 StrictlyLowerTriangular{Int64, Vector{Int64}}:
0 0 0 0
5 0 0 0
9 10 0 0
13 14 15 0GeometricOptimizers.StrictlyUpperTriangular — Type
StrictlyUpperTriangular(S::AbstractVector, n::Int)Build an upper-triangular matrix from a vector.
An upper-triangular matrix is an $n\times{}n$ matrix that has zeros on the diagonal and on the lower triangular.
The data are stored in a vector $S$ similarly to other matrices. See StrictlyLowerTriangular, SkewSymMatrix and SymmetricMatrix.
The struct has two fields: S and n. The first stores all the entries of the matrix in a sparse fashion (in a vector) and the second is the dimension $n$ for $A\in\mathbb{R}^{n\times{}n}$.
adjoint (U') returns a StrictlyLowerTriangular built around the same storage vector, not a copy: parent(U') === parent(U) holds, so writing into the adjoint also writes into U. Reusing the storage transposes without conjugating, so this method is defined for a real element type only; a complex one falls through to LinearAlgebra's lazy Adjoint, which conjugates and does not alias.
Examples
using GeometricOptimizers
S = [1, 2, 3, 4, 5, 6]
StrictlyUpperTriangular(S, 4)
# output
4×4 StrictlyUpperTriangular{Int64, Vector{Int64}}:
0 1 2 4
0 0 3 5
0 0 0 6
0 0 0 0GeometricOptimizers.StrictlyUpperTriangular — Method
StrictlyUpperTriangular(A::AbstractMatrix)Build an upper-triangular matrix from a matrix.
This is done by taking the upper right of that matrix.
Examples
using GeometricOptimizers
M = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16]
StrictlyUpperTriangular(M)
# output
4×4 StrictlyUpperTriangular{Int64, Vector{Int64}}:
0 2 3 4
0 0 7 8
0 0 0 12
0 0 0 0GeometricOptimizers.VectorStorageMatrix — Type
VectorStorageMatrixThe structured matrix types that keep their free parameters in one vector, reachable as parent(A): SkewSymMatrix, SymmetricMatrix and the two AbstractTriangulars.
Each of them stores $n(n\pm1)/2$ numbers behind an $n \times n$ interface, so none of the generic AbstractArray methods, which either broadcast or reshape, is usable for them:
- three of the four have no
setindex!for a broadcast to write through.SkewSymMatrixand the two triangulars cannot represent an arbitrary matrix at all, so there is no entry to assign.SymmetricMatrixis the exception — it does have one (writing $[A]_{ij}$ writes $[A]_{ji}$ too, which is what a symmetric matrix means), so the broadcast would give the right answer for that one type, at twice the work and only as long as it stays the exception. similarhas to preserve the type, because the optimizer caches allocate their scratch with it and then require every array to have the same type as the parameter. TheAbstractArrayfallback returns a denseMatrix.- flattening has to round trip through the free parameters. A generic
AbstractMatrixtreatment reshapes the flattened vector back to $n \times n$, and $n(n\pm1)/2$ numbers do not reshape to that.NeuralNetworkParametersasksBase.parentinstead, throughfreeparameters.
For every one of these types the free parameters are the coordinates the optimizer should work in, so each primitive is the corresponding operation on parent. _add!, _rmul! and _difference! live next to the rest of their family in optimizers/named_tuple_wrapper.jl, l2norm in optimizers/optimizer_status.jl; update_section! in global_sections/global_sections.jl splits on this alias for the same reason.
This is what lets a SymmetricMatrix or a triangular matrix be an optimizer parameter — which is what GeometricMachineLearning's SympNet, symplectic-attention and volume-preserving layers need, and what this package could not do before.
The alias lives in a file of its own because it is needed by global_sections.jl, which is included long before the primitives are.
GeometricOptimizers.AbstractLieAlgHorMatrix — Type
AbstractLieAlgHorMatrix <: AbstractMatrixAbstractLieAlgHorMatrix is a supertype for various horizontal components of Lie algebras. We usually call this $\mathfrak{g}^\mathrm{hor}$.
See StiefelLieAlgHorMatrix, GrassmannLieAlgHorMatrix, SymplecticLieAlgHorMatrix and BiorthogonalLieAlgHorMatrix for concrete examples.
Base.:* — Method
*(B::AbstractLieAlgHorMatrix, C::AbstractMatrix)
*(C::AbstractMatrix, B::AbstractLieAlgHorMatrix)
*(B::AbstractLieAlgHorMatrix, c::AbstractVector)The product, taken on the stored blocks rather than through getindex.
Without these the product falls through to the generic AbstractMatrix path, which asks the lift for one entry at a time. That is scalar indexing, so it cannot run on a device at all — the third wrapper in this package to meet that gap, after StiefelProjection and the two GeometricOptimizers.AbstractTriangulars.
A lift is block $\begin{pmatrix} A & -B^T \\ B & \mathbb{O} \end{pmatrix}$, with $A$ absent for a GrassmannLieAlgHorMatrix, and with the Hamiltonian $\mathcal{A}$ and the symplectic adjoint $\mathcal{B}^+$ in place of $A$ and $B^T$ for a SymplecticLieAlgHorMatrix, and with a block $C$ of its own in place of $-B^T$ for a BiorthogonalLieAlgHorMatrix. So the product against an $N\times{}m$ matrix is three block products — two for a Grassmann lift — and nothing else. No kernel is needed and none is written, which is where this differs from the triangulars: those hold a packed vector their getindex unpacks, while a lift holds ordinary blocks and a SkewSymMatrix that already carries a kernel-backed product of its own. The per-type part is the first $n$ rows, _hor_top_rows, beside each concrete lift.
*(C, B) is written -transpose(B * permutedims(C)), on the identity $B^T = -B$ of a Stiefel and a Grassmann lift. A symplectic and a biorthogonal lift do not satisfy it and take their own _rmul on the blocks. A row vector x takes transpose(x) in place of permutedims(C), and the vector form goes through the matrix one as a single column. transpose and permutedims, and not adjoint, wherever one appears, for the reason the comment on _rmul(::AbstractMatrix, ::SkewSymMatrix) in special_matrices/skew_symmetric.jl gives at length: the identity is a statement about the transpose, and getindex builds the off-diagonal blocks entrywise without conjugating. The two agree on a real element type and disagree on a complex one.
Base.one — Method
one(B::AbstractLieAlgHorMatrix)The $N\times{}N$ identity, built with a KernelAbstractions kernel.
Base.one(::AbstractMatrix) writes the diagonal in a scalar-indexed loop, which is what a GPU array cannot serve; geodesic reaches this on every retraction, for every lift type. GeometricOptimizers.𝔄, whose argument is a bare matrix, builds its $2n\times{}2n$ identities through GeometricOptimizers.unit_matrix for the same reason.
Base.parent — Method
parent(B::AbstractLieAlgHorMatrix)The tuple of blocks B's free parameters are stored in — (A, B) for a StiefelLieAlgHorMatrix, (B,) for a GrassmannLieAlgHorMatrix, (A₁, B₁, C₁, B) for a SymplecticLieAlgHorMatrix, (A, B, C) for a BiorthogonalLieAlgHorMatrix — and not the single array every other parent this package defines returns.
Every operation on a lift that is elementwise in the free parameters — as opposed to in the ambient $N\times{}N$ matrix, which has no setindex! and counts each off-diagonal block twice — is written once over this tuple rather than once per lift type. That is assign! below, and l2norm, and the _difference! / _add! / _rmul! family in named_tuple_wrapper.jl and the moment update of Adam, which reach the tuple through freeparameters. So a GrassmannManifold is driven through an Optimizer by the same code as a StiefelManifold.
The docstring is attached to the signature and not to the bare Base.parent: the package also defines parent for Manifold, SkewSymMatrix, SymmetricMatrix and AbstractTriangular, each of which returns the single array it wraps, and a signature-less docstring would be shown as the general meaning of parent for all of them.
GeometricOptimizers.manifold_type — Function
manifold_type(B::AbstractLieAlgHorMatrix)The manifold a retraction of B lands on.
$\mathfrak{g}^\mathrm{hor}$ is the horizontal component of the Lie algebra of a specific homogeneous space, so the lift already determines where the retraction maps to. This is what lets geodesic and cayley be written once for every manifold rather than once for each.
GeometricOptimizers.StiefelLieAlgHorMatrix — Type
StiefelLieAlgHorMatrix(A::SkewSymMatrix, B::AbstractMatrix, N::Integer, n::Integer)Build an instance of StiefelLieAlgHorMatrix based on a skew-symmetric matrix A and an arbitrary matrix B.
An element of StiefelLieAlgMatrix takes the form:
\[\begin{pmatrix} A & -B^T \\ B & \mathbb{O} \end{pmatrix},\]
where $A$ is skew-symmetric (this is SkewSymMatrix in GeometricOptimizers).
Also see GrassmannLieAlgHorMatrix.
Extended help
StiefelLieAlgHorMatrix is the horizontal component of the Lie algebra of skew-symmetric matrices (with respect to the canonical metric).
The projection here is: $\pi:S \to SE$ where
\[E = \begin{bmatrix} \mathbb{I}_{n} \\ \mathbb{O}_{(N-n)\times{}n} \end{bmatrix}.\]
The matrix $E$ is implemented under StiefelProjection in GeometricOptimizers.
GeometricOptimizers.StiefelLieAlgHorMatrix — Method
StiefelLieAlgHorMatrix(D::AbstractMatrix, n::Integer)Take a big matrix as input and build an instance of StiefelLieAlgHorMatrix.
The integer $N$ in $St(n, N)$ is the number of rows of D.
Extended help
If the constructor is called with a big $N\times{}N$ matrix, then the projection is performed the following way:
\[\begin{pmatrix} A & B_1 \\ B_2 & D \end{pmatrix} \mapsto \begin{pmatrix} \mathrm{skew}(A) & -B_2^T \\ B_2 & \mathbb{O} \end{pmatrix}.\]
The operation $\mathrm{skew}:\mathbb{R}^{n\times{}n}\to\mathcal{S}_\mathrm{skew}(n)$ is the skew-symmetrization operation. This is equivalent to calling of SkewSymMatrix with an $n\times{}n$ matrix.
This can also be seen as the operation:
\[D \mapsto \Omega(E, DE) = \mathrm{skew}\left(2 \left(\mathbb{I} - \frac{1}{2} E E^T \right) DE E^T\right).\]
Also see GeometricOptimizers.Ω.
GeometricOptimizers.GrassmannLieAlgHorMatrix — Type
GrassmannLieAlgHorMatrix(B::AbstractMatrix, N::Integer, n::Integer)Build an instance of GrassmannLieAlgHorMatrix based on an arbitrary matrix B of size $(N-n)\times{}n$.
GrassmannLieAlgHorMatrix is the horizontal component of the Lie algebra of skew-symmetric matrices (with respect to the canonical metric).
Extended help
The projection here is: $\pi:S \to SE/\sim$ where
\[E = \begin{bmatrix} \mathbb{I}_{n} \\ \mathbb{O}_{(N-n)\times{}n} \end{bmatrix},\]
and the equivalence relation is
\[V_1 \sim V_2 \iff \exists A\in\mathcal{S}_\mathrm{skew}(n) \text{ such that } V_2 = V_1 + \begin{bmatrix} A \\ \mathbb{O} \end{bmatrix}\]
An element of GrassmannLieAlgMatrix takes the form:
\[\begin{pmatrix} \bar{\mathbb{O}} & -B^T \\ B & \mathbb{O} \end{pmatrix},\]
where $\bar{\mathbb{O}}\in\mathbb{R}^{n\times{}n}$ and $\mathbb{O}\in\mathbb{R}^{(N - n)\times(N-n)}.$
GeometricOptimizers.GrassmannLieAlgHorMatrix — Method
GrassmannLieAlgHorMatrix(D::AbstractMatrix, n::Integer)Take a big matrix as input and build an instance of GrassmannLieAlgHorMatrix.
The integer $N$ in $Gr(n, N)$ here is the number of rows of D.
Extended help
If the constructor is called with a big $N\times{}N$ matrix, then the projection is performed the following way:
\[\begin{pmatrix} A & B_1 \\ B_2 & D \end{pmatrix} \mapsto \begin{pmatrix} \bar{\mathbb{O}} & -B_2^T \\ B_2 & \mathbb{O} \end{pmatrix}.\]
This can also be seen as the operation:
\[D \mapsto \Omega(E, DE - EE^TDE),\]
where $\Omega$ is the horizontal lift GeometricOptimizers.Ω.
GeometricOptimizers.SymplecticLieAlgHorMatrix — Type
SymplecticLieAlgHorMatrix(A₁, B₁::SymmetricMatrix, C₁::SymmetricMatrix, B, N, n)The horizontal component $\mathfrak{g}^\mathrm{hor}$ of the Lie algebra of the symplectic group, for the SymplecticStiefelManifold of $2N\times2n$ matrices. The fields N and n hold the sizes of a point, $2N$ and $2n$, as they do for the other lifts.
An element is the $2N\times2N$ matrix
\[\begin{pmatrix} \mathcal{A} & -\mathcal{B}^+ \\ \mathcal{B} & \mathbb{O} \end{pmatrix}, \qquad \mathcal{A} = \begin{pmatrix} A_1 & B_1 \\ C_1 & -A_1^T \end{pmatrix},\]
where $A_1$ is an arbitrary $n\times{}n$ matrix and $B_1$ and $C_1$ are symmetric, so that $\mathcal{A}\in\mathfrak{sp}(2n)$ is Hamiltonian, $\mathcal{B}$ is an arbitrary $(2N - 2n)\times2n$ matrix, and $\mathcal{B}^+ = \mathbb{J}_{2n}^T\mathcal{B}^T\mathbb{J}_{2N - 2n}$ is its symplectic adjoint. This is the StiefelLieAlgHorMatrix with the transpose replaced by the symplectic adjoint and the skew-symmetric block by a Hamiltonian one.
Also see StiefelLieAlgHorMatrix and GrassmannLieAlgHorMatrix.
Extended help
This is the horizontal space that [12] give below their (3.4): the complement of the vertical space with respect to the bi-invariant pseudo-Riemannian metric $h$ of their (2.1). It is the only one of their two horizontal spaces that is the same subspace of the Lie algebra at every point. The horizontal space (3.13) of the Riemannian metric $g$ depends on the point, so it has no global representation of this kind. The metric the gradient is taken in is a separate matter; see GeometricOptimizers.gradient_rep!.
[12] order the columns of the symplectic group so that $E$ picks the columns $1$ to $n$ and $N + 1$ to $N + n$. In that order $\mathcal{B}$ above is $\begin{pmatrix} A_3 & B_2 \\ C_2 & -A_2 \end{pmatrix}$. A GlobalSection of this package stores $\lambda(U) = [U\ \ U^s]$, the point first and its symplectic completion global_section after it, as it does for the StiefelManifold. So $E$ is the first $2n$ columns, as StiefelProjection gives it. In this basis the Poisson tensor is
\[\bar{\mathbb{J}} = \begin{pmatrix} \mathbb{J}_{2n} & \mathbb{O} \\ \mathbb{O} & \mathbb{J}_{2N - 2n} \end{pmatrix},\]
the section satisfies $\lambda(U)^T\mathbb{J}_{2N}\lambda(U) = \bar{\mathbb{J}}$, the lift satisfies $\Omega^T\bar{\mathbb{J}} + \bar{\mathbb{J}}\Omega = \mathbb{O}$, and a retraction of it is a matrix $R$ with $R^T\bar{\mathbb{J}}R = \bar{\mathbb{J}}$. So $\lambda(U)R$ is a section again and $\lambda(U)RE$ a point of the manifold. A retraction itself, which cayley and geodesic wrap in a SymplecticStiefelManifold, preserves $\bar{\mathbb{J}}$ and not $\mathbb{J}_{2N}$, so check does not apply to it.
GeometricOptimizers.SymplecticLieAlgHorMatrix — Method
SymplecticLieAlgHorMatrix(D::AbstractMatrix, n::Integer)Take a big matrix as input and build an instance of SymplecticLieAlgHorMatrix.
D is $2N\times2N$ and n is $2n$, the number of columns of a point. The projection is
\[\begin{pmatrix} A & B_1 \\ B_2 & D \end{pmatrix} \mapsto \begin{pmatrix} \mathrm{ham}(A) & -B_2^+ \\ B_2 & \mathbb{O} \end{pmatrix},\]
with $\mathrm{ham}(A) = \frac{1}{2}(A - A^+)$ the projection onto the Hamiltonian matrices, the counterpart of the skew-symmetrization of StiefelLieAlgHorMatrix(::AbstractMatrix, ::Integer).
GeometricOptimizers.BiorthogonalLieAlgHorMatrix — Type
BiorthogonalLieAlgHorMatrix(A, B, C, N, n)The horizontal component $\mathfrak{g}^\mathrm{hor}$ of the Lie algebra $\mathfrak{gl}(N)$ for the BiorthogonalManifold of pairs of $N\times{}n$ matrices. An element is the $N\times{}N$ matrix
\[\begin{pmatrix} A & C \\ B & \mathbb{O} \end{pmatrix},\]
with $A\in\mathbb{R}^{n\times{}n}$, $B\in\mathbb{R}^{(N-n)\times{}n}$ and $C\in\mathbb{R}^{n\times(N-n)}$ arbitrary. Its dimension is $n^2 + 2(N-n)n = 2Nn - n^2$, the dimension of the manifold.
This is the StiefelLieAlgHorMatrix with the two constraints of $\mathfrak{so}(N)$ dropped: $A$ need not be skew-symmetric, and the upper right block is a block of its own and not $-B^T$. Also see SymplecticLieAlgHorMatrix.
Extended help
The general linear group acts on the pairs by $g\cdot(\Phi, \Psi) = (g\Phi, g^{-T}\Psi)$, and an element $X$ of its Lie algebra by $X\cdot(\Phi, \Psi) = (X\Phi, -X^T\Psi)$. At the distinct point $(E, E)$, with $E$ the first $n$ columns of the identity (StiefelProjection), this is $(XE, -X^TE)$: the first $n$ columns and the first $n$ rows of $X$. The vertical space, on which both vanish, is the Lie algebra of the isotropy group $GL(N - n)$, the matrices that are zero outside their lower right block, and its complement above is the same subspace of $\mathfrak{gl}(N)$ at every point. global_rep maps a tangent vector into it, see there.
Under $\mathfrak{gl}(N)\to\mathfrak{sp}(2N)$, $X\mapsto\mathrm{diag}(X, -X^T)$, this lift is the part of a SymplecticLieAlgHorMatrix with $B_1 = C_1 = \mathbb{O}$, $A_1 = A$ and the block-diagonal $\mathcal{B} = \mathrm{diag}(B, -C^T)$.
GeometricOptimizers.BiorthogonalLieAlgHorMatrix — Method
BiorthogonalLieAlgHorMatrix(D::AbstractMatrix, n::Integer)Take a big $N\times{}N$ matrix and build its horizontal projection:
\[\begin{pmatrix} A & C \\ B & D_{22} \end{pmatrix} \mapsto \begin{pmatrix} A & C \\ B & \mathbb{O} \end{pmatrix}.\]
The vertical space is the lower right block, so the projection drops it and keeps the rest as it is.
GeometricOptimizers.StiefelProjection — Method
StiefelProjection(B::AbstractLieAlgHorMatrix)Extract necessary information from B and build an instance of StiefelProjection.
Necessary information here refers to the backend, the data type and the size of the matrix.
The size is queried through B.N and B.n.
Examples
using GeometricOptimizers
using GeometricOptimizers: StiefelProjection
B₁ = rand(StiefelLieAlgHorMatrix, 5, 2)
B₂ = rand(GrassmannLieAlgHorMatrix, 5, 2)
E = [1. 0.; 0. 1.; 0. 0.; 0. 0.; 0. 0.]
StiefelProjection(B₁) ≈ StiefelProjection(B₂) ≈ E
# output
true