Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symplectic Grassmann #700

Merged
merged 70 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
592e3a0
Start documentation of the symplectic Grassmann.
kellertuer Dec 23, 2023
c4f69c3
Merge branch 'master' into kellertuer/more-grassmann
kellertuer Dec 29, 2023
0ed78d5
Finish manifold doc string by adding the tangent spaces.
kellertuer Jan 3, 2024
3b3d1e3
A bit of work on the symplectic inverse.
kellertuer Jan 3, 2024
5d800f6
Adapt a few docs and default shows, implement symplectic Grassmann ch…
kellertuer Jan 5, 2024
c80df09
Undo a chick search-and-replace, that was not careful enough.
kellertuer Jan 5, 2024
60d2944
Fix docs and tests.
kellertuer Jan 5, 2024
95c9848
Further work on Symplectic Grasmann
kellertuer Jan 9, 2024
01434a8
Unify notation to use UTF8 where possible and use J for the symplecti…
kellertuer Jan 11, 2024
5f6409f
delete an accidentially moved file
kellertuer Jan 11, 2024
ab162ba
Worked a bit on math formulae.
kellertuer Jan 11, 2024
770bf76
Rearrange code to avoid redefining functions.
kellertuer Jan 12, 2024
f9769a1
Fix improvised test, fix documentation.
kellertuer Jan 13, 2024
3f5137e
implement `rand!` for Hamiltonians. Deprecate `rand_hamiltonian`.
kellertuer Jan 14, 2024
f4f6cef
Implement exp and the Caley retraction in the quivalence class repres…
kellertuer Jan 15, 2024
5b22c6c
Simplify math.
kellertuer Jan 15, 2024
8982971
Deprecate Symplectic in favour of SymplecticMatrices (cf. #701 Point 1)
kellertuer Jan 18, 2024
385f9b5
Rename SymplecticMatrix to SymplecticElement (#701, Point 2).
kellertuer Jan 18, 2024
de1cee2
this fixes a typo and I am getting a bit tired so I should stop also …
kellertuer Jan 18, 2024
9f8b719
Fix references.
kellertuer Jan 19, 2024
9173543
Unify and extend rands. Introduce Riemannian Gradients.
kellertuer Jan 19, 2024
273de80
Apply suggestions from code review
kellertuer Jan 19, 2024
72d04e1
Fix 2 typos.
kellertuer Jan 19, 2024
9b3dee3
Replace \to with → in LaTeX formulae.
kellertuer Jan 20, 2024
52db300
Start new test file, fix an old test.
kellertuer Jan 20, 2024
009622b
Fix News.md
kellertuer Jan 20, 2024
aca6452
Improve memory a bit.
kellertuer Jan 20, 2024
1e9da05
Fix doc strings.
kellertuer Jan 20, 2024
22717df
$ → `` for math, \mathbb R → ℝ
kellertuer Jan 20, 2024
4d5c62c
Missed a p.
kellertuer Jan 20, 2024
020b0b5
And another symbol.
kellertuer Jan 20, 2024
08712a2
My VS Code reportet an error on this line, removing the "" fixed it, …
kellertuer Jan 20, 2024
c193a8e
Code Coverage for Symplectic Stiefel.
kellertuer Jan 20, 2024
7af7ae3
Work on Symplectic test coverage.
kellertuer Jan 20, 2024
8021ed1
fix a typo.
kellertuer Jan 21, 2024
b94a8e4
A few more tests.
kellertuer Jan 21, 2024
e10d353
Fix embedding functions.
kellertuer Jan 21, 2024
4a149fc
add a few nicer functions to Hamiltonian and extend test coverage.
kellertuer Jan 21, 2024
ef55fa7
Mixinf Hamiltonian with other matrices introduces 120+ ambiguities, l…
kellertuer Jan 21, 2024
e4015ab
Forgot to remove the mixed tests. Brain is melting.
kellertuer Jan 21, 2024
09202d0
fix a too strict test.
kellertuer Jan 21, 2024
b1548bb
MOre tst coverage.
kellertuer Jan 21, 2024
d587821
Merge branch 'master' into kellertuer/more-grassmann
kellertuer Jan 21, 2024
1ed51cb
A bit of testcoverage
kellertuer Jan 22, 2024
bece83a
Maybe increase test cov.
kellertuer Jan 22, 2024
fc4c1e5
Merge branch 'master' into kellertuer/more-grassmann
kellertuer Jan 23, 2024
324c791
This should finish code coverage up to one final line, a valid Projec…
kellertuer Jan 23, 2024
1a21e9b
Add a line for the case that the vector is correct to return nothing.
kellertuer Jan 23, 2024
2f438e2
Checking a new formula for the conversion, still have to debug this.
kellertuer Jan 23, 2024
1958357
Fix a test,
kellertuer Jan 24, 2024
b986b8b
finish tests. 🚀
kellertuer Jan 24, 2024
db2ce47
Apply suggestions from code review
kellertuer Jan 24, 2024
c2b71bc
Fiinalise PR by fixing rand on Hamiltonian and update the docs for SpGr.
kellertuer Jan 24, 2024
bfac83e
bump version.
kellertuer Jan 24, 2024
6fb6287
More $ -> `` (trying to remove the one warning from documenter but ca…
kellertuer Jan 24, 2024
6d577ea
Apply suggestions from code review
kellertuer Jan 24, 2024
2657758
fix test tolerances.
kellertuer Jan 24, 2024
91a09eb
Update src/manifolds/SymplecticGrassmann.jl
kellertuer Jan 24, 2024
02a59f5
Edit rand doc string.
kellertuer Jan 24, 2024
68b3430
Merge branch 'kellertuer/more-grassmann' of github.com:JuliaManifolds…
kellertuer Jan 24, 2024
22b27ff
Update src/manifolds/Hamiltonian.jl
kellertuer Jan 24, 2024
7cf4731
Update src/manifolds/Hamiltonian.jl
kellertuer Jan 24, 2024
d281355
Update src/manifolds/Hamiltonian.jl
kellertuer Jan 24, 2024
e3d83da
Update src/manifolds/Hamiltonian.jl
kellertuer Jan 24, 2024
32aa72e
Update src/manifolds/SymplecticGrassmannStiefel.jl
kellertuer Jan 24, 2024
cff3387
Adress points from code review.
kellertuer Jan 24, 2024
c25e870
I am not sure which AI / auotcomplete stepped in there :/.
kellertuer Jan 24, 2024
6eb0d3e
Rephrase a docstring.
kellertuer Jan 25, 2024
1a8db36
Merge branch 'kellertuer/more-grassmann' of github.com:JuliaManifolds…
kellertuer Jan 25, 2024
9500bd5
Fix the seed, raise tolerances – again.
kellertuer Jan 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [unreleased] 2023-12-x

### Added

* added the real symplectic Grassmann manifold `SymplecticGrassmann`

## [0.9.11] – 2023-12-27

### Fixed
Expand Down Expand Up @@ -37,27 +43,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Improved distribution of random vector generation for rotation matrices and complex circle.

## [0.9.7] - 2023-11-14
## [0.9.7] * 2023-11-14
kellertuer marked this conversation as resolved.
Show resolved Hide resolved

### Fixed

* Fixed `is_flat` for `CholeskySpace` and `SymmetricPositiveDefinite` with `LogCholeskyMetric` [https://github.com/JuliaManifolds/Manifolds.jl/issues/684](https://github.com/JuliaManifolds/Manifolds.jl/issues/684).

## [0.9.6] - 2023-11-09
## [0.9.6] * 2023-11-09

### Fixed

* Fixed real coefficient basis for complex circle (an issue exposed by [https://github.com/JuliaManifolds/ManifoldsBase.jl/pull/173](https://github.com/JuliaManifolds/ManifoldsBase.jl/pull/173)).
* Fixed `VeeOrthogonalBasis` test for non-real manifolds.

## [0.9.5] - 2023-11-08
## [0.9.5] * 2023-11-08

### Changed

* `identity_element` now returns a complex matrix for unitary group.
* `number_of_coordinates` is now exported.

## [0.9.4] - 2023-11-06
## [0.9.4] * 2023-11-06

### Added

Expand All @@ -72,27 +78,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Fixed issue with incorrect implementation of `apply_diff_group` in `GroupOperationAction` with left backward and right forward action [#669](https://github.com/JuliaManifolds/Manifolds.jl/issues/669).

## [0.9.3] - 2023-10-28
## [0.9.3] * 2023-10-28

### Added

* Support for `BoundaryValueDiffEq` v5.

## [0.9.2] - 2023-10-27
## [0.9.2] * 2023-10-27

### Added

* `rand(G; vector_at=Identity(G))` now works for translation, special orthogonal and special Euclidean groups `G` (issue [#665](https://github.com/JuliaManifolds/Manifolds.jl/issues/665)).
* `get_embedding` now works for `GeneralUnitaryMultiplicationGroup`.
* Github action that checks for NEWS.md changes.

## [0.9.1] - 2023-10-25
## [0.9.1] * 2023-10-25

### Added

* a new retraction and its inverse for the fixed Rank Manifolds, the orthographic retraction.

## [0.9.0] - 2023-10-24
## [0.9.0] * 2023-10-24

### Added

Expand Down
2 changes: 2 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ makedocs(;
"Generalized Stiefel" => "manifolds/generalizedstiefel.md",
"Generalized Grassmann" => "manifolds/generalizedgrassmann.md",
"Grassmann" => "manifolds/grassmann.md",
"Hamiltonian" => "manifolds/hamiltonian.md",
mateuszbaran marked this conversation as resolved.
Show resolved Hide resolved
"Hyperbolic space" => "manifolds/hyperbolic.md",
"Lorentzian manifold" => "manifolds/lorentz.md",
"Multinomial doubly stochastic matrices" => "manifolds/multinomialdoublystochastic.md",
Expand All @@ -134,6 +135,7 @@ makedocs(;
"SPD, fixed determinant" => "manifolds/spdfixeddeterminant.md",
"Symmetric positive semidefinite fixed rank" => "manifolds/symmetricpsdfixedrank.md",
"Symplectic" => "manifolds/symplectic.md",
"Symplectic Grassmann" => "manifolds/symplecticgrassmann.md",
"Symplectic Stiefel" => "manifolds/symplecticstiefel.md",
"Torus" => "manifolds/torus.md",
"Tucker" => "manifolds/tucker.md",
Expand Down
7 changes: 7 additions & 0 deletions docs/src/manifolds/hamiltonian.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Symmetric matrices

```@autodocs
Modules = [Manifolds]
Pages = ["manifolds/Hamiltonian.jl"]
Order = [:type, :function]
```
30 changes: 30 additions & 0 deletions docs/src/manifolds/symplecticgrassmann.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# (Real) Symplectic Grassmann

```@autodocs
Modules = [Manifolds]
Pages = ["manifolds/SymplecticGrassmann.jl"]
Order = [:type, :function]
```

## The (default) symplectic Stiefel representation

```@autodocs
Modules = [Manifolds]
Pages = ["manifolds/SymplecticGrassmannStiefel.jl"]
Order = [:type, :function]
```

## The symplectic projector representation

```@autodocs
Modules = [Manifolds]
Pages = ["manifolds/SymplecticGrassmannProjector.jl"]
Order = [:type, :function]
```

## Literature

```@bibliography
Pages = ["symplecticgrassmann.md"]
Canonical=false
```
2 changes: 1 addition & 1 deletion docs/src/manifolds/symplecticstiefel.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Symplectic Stiefel
# (Real) Symplectic Stiefel

The [`SymplecticStiefel`](@ref) manifold, denoted $\operatorname{SpSt}(2n, 2k)$,
represents canonical symplectic bases of $2k$ dimensonal symplectic subspaces of $\mathbb{R}^{2n \times 2n}$.
Expand Down
16 changes: 13 additions & 3 deletions src/Manifolds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module Manifolds

import Base:
^,
angle,
copyto!,
convert,
Expand Down Expand Up @@ -444,8 +445,6 @@ include("manifolds/SymmetricPositiveDefiniteAffineInvariant.jl")
include("manifolds/SymmetricPositiveDefiniteLogCholesky.jl")
include("manifolds/SymmetricPositiveDefiniteLogEuclidean.jl")
include("manifolds/SymmetricPositiveSemidefiniteFixedRank.jl")
include("manifolds/Symplectic.jl")
include("manifolds/SymplecticStiefel.jl")
include("manifolds/Tucker.jl")
#
include("manifolds/ProbabilitySimplex.jl")
Expand All @@ -462,6 +461,13 @@ include("manifolds/KendallsShapeSpace.jl")
# Introduce the quotient, Grassmann, only after Stiefel
include("manifolds/Grassmann.jl")

# Introduce Symplectic and so on manifolds only after Grassmann
# Since that defines the StiefelPoint, StiefelTVector
include("manifolds/Symplectic.jl")
include("manifolds/Hamiltonian.jl") # Hamiltonian requires symplectic
include("manifolds/SymplecticStiefel.jl")
include("manifolds/SymplecticGrassmann.jl") # Requires SymplecticStiefel

# Product or power based manifolds
include("manifolds/Torus.jl")
include("manifolds/Multinomial.jl")
Expand Down Expand Up @@ -659,6 +665,7 @@ export Euclidean,
SPDFixedDeterminant,
SymmetricPositiveSemidefiniteFixedRank,
Symplectic,
SymplecticGrassmann,
SymplecticStiefel,
SymplecticMatrix,
Torus,
Expand All @@ -682,7 +689,7 @@ export HyperboloidTVector,
ProjectorTVector,
StiefelTVector
export AbstractNumbers, ℝ, ℂ, ℍ

export Hamiltonian
# decorator manifolds
export AbstractDecoratorManifold
export IsIsometricEmbeddedManifold, IsEmbeddedManifold, IsEmbeddedSubmanifold
Expand Down Expand Up @@ -775,6 +782,7 @@ export CachedBasis,
export ComponentManifoldError, CompositeManifoldError
# Functions on Manifolds
export ×,
^,
action_side,
allocate,
allocate_result,
Expand Down Expand Up @@ -900,6 +908,8 @@ export ×,
skewness,
std,
sym_rem,
symplectic_inverse,
symplectic_inverse!,
symplectic_inverse_times,
symplectic_inverse_times!,
submanifold,
Expand Down
4 changes: 2 additions & 2 deletions src/manifolds/Grassmann.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ is_flat(M::Grassmann) = manifold_dimension(M) == 1
@doc raw"""
manifold_dimension(M::Grassmann)

Return the dimension of the [`Grassmann(n,k,𝔽)`](@ref) manifold `M`, i.e.
Return the dimension of the [`Grassmann`](@ref)`(n,k,𝔽)` manifold `M`, i.e.

````math
\dim \operatorname{Gr}(n,k) = k(n-k) \dim_ℝ 𝔽,
Expand Down Expand Up @@ -195,7 +195,7 @@ function get_total_space(M::Grassmann{Tuple{Int,Int},𝔽}) where {𝔽}
end

#
# Reprenter specific implementations in their corresponding subfiles
# Representer specific implementations in their corresponding subfiles
#
include("GrassmannStiefel.jl")
include("GrassmannProjector.jl")
Expand Down
65 changes: 65 additions & 0 deletions src/manifolds/Hamiltonian.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#
# This file requires Symplectic to be defined, since it need the symplectic inverse A^+
# This type is used in the Symplectic Grassmann
@doc raw"""
Hamiltonian{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T}

A type to store an hamiltonien matrix, i.e. A square matrix matrix for which ``A^+ = -A`` where
kellertuer marked this conversation as resolved.
Show resolved Hide resolved

```math
A^+ = J_{2n}A^{\mathrm{T}}J_{2n}, \qquad J_{2n} \begin{pmatrix} 0 & I_n\\-I_n & 0 \end{pmatrix},
```

and ``I_n`` denotes the ``n × n``
"""
struct Hamiltonian{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T}
value::S
function Hamiltonian(A::S) where {T,S<:AbstractMatrix{<:T}}
n = div(size(A, 1), 2)
@assert size(A, 1) == 2 * n "The first dimension of A ($(size(A,1))) is not even"
@assert size(A, 2) == 2 * n "The matrix A is of size ($(size(A))), which is not square."
return new{T,S}(A)

Check warning on line 21 in src/manifolds/Hamiltonian.jl

View check run for this annotation

Codecov / codecov/patch

src/manifolds/Hamiltonian.jl#L17-L21

Added lines #L17 - L21 were not covered by tests
end
end
# Avoid double wrapping / unwrap if that happened
Hamiltonian(A::Hamiltonian) = Hamiltonian(A.value)

Check warning on line 25 in src/manifolds/Hamiltonian.jl

View check run for this annotation

Codecov / codecov/patch

src/manifolds/Hamiltonian.jl#L25

Added line #L25 was not covered by tests
# Conversion
function Matrix(A::Hamiltonian)
return copy(A.value)

Check warning on line 28 in src/manifolds/Hamiltonian.jl

View check run for this annotation

Codecov / codecov/patch

src/manifolds/Hamiltonian.jl#L27-L28

Added lines #L27 - L28 were not covered by tests
kellertuer marked this conversation as resolved.
Show resolved Hide resolved
end

@doc raw"""
^(A::Hamilonian, ::typeof(+))

Compute the [`symplectic_inverse`](@ref) of a Hamiltonian (A)
"""
function ^(A::Hamiltonian, ::typeof(+))
return Hamiltonian(symplectic_inverse(A.value))

Check warning on line 37 in src/manifolds/Hamiltonian.jl

View check run for this annotation

Codecov / codecov/patch

src/manifolds/Hamiltonian.jl#L36-L37

Added lines #L36 - L37 were not covered by tests
end

@doc raw"""
is_hamiltonian(A; kwargs...)
kellertuer marked this conversation as resolved.
Show resolved Hide resolved

Test whether a matrix `A` is hamiltonian.
The test consists of verifying whether

```math
A^+ = -A
```
where ``A^+`` denotes the [`symplectic_inverse`](@ref) of `A`.

The passed keyword arguments are passed on to the [`isapprox`](@ref)
check within
"""
function is_hamiltonian(A::AbstractMatrix; kwargs...)
return isapprox(symplectic_inverse(A), -A; kwargs...)

Check warning on line 55 in src/manifolds/Hamiltonian.jl

View check run for this annotation

Codecov / codecov/patch

src/manifolds/Hamiltonian.jl#L54-L55

Added lines #L54 - L55 were not covered by tests
end
function is_hamiltonian(A::Hamiltonian; kwargs...)
return isapprox((A^+).value, -A.value; kwargs...)

Check warning on line 58 in src/manifolds/Hamiltonian.jl

View check run for this annotation

Codecov / codecov/patch

src/manifolds/Hamiltonian.jl#L57-L58

Added lines #L57 - L58 were not covered by tests
end

function show(io::IO, ::MIME"text/plain", A::Hamiltonian)
return print(io, "Hamiltonian($(A.value))")

Check warning on line 62 in src/manifolds/Hamiltonian.jl

View check run for this annotation

Codecov / codecov/patch

src/manifolds/Hamiltonian.jl#L61-L62

Added lines #L61 - L62 were not covered by tests
end

size(A::Hamiltonian) = size(A.value)

Check warning on line 65 in src/manifolds/Hamiltonian.jl

View check run for this annotation

Codecov / codecov/patch

src/manifolds/Hamiltonian.jl#L65

Added line #L65 was not covered by tests
Loading
Loading