Skip to content

Commit 65780dc

Browse files
Introduce AbstractApproximationMethod (#177)
* Initial sketch of an abstract estimation method type. * Rename AbstractEstimationMethod to AbstractApproximationMethod * Fix docs. * Update our reference. --------- Co-authored-by: Mateusz Baran <[email protected]>
1 parent f5d3189 commit 65780dc

12 files changed

+264
-26
lines changed

NEWS.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
* `EmbeddedVectorTransport` to use a vector transport in the embedding and a final projection.
12+
* An `AbstractApproximationMethod` to specify estimation methods for other more general functions,
13+
as well as a `default_approximation_method` to specify defaults on manifolds.
14+
* An `EmbeddedVectorTransport` to use a vector transport in the embedding and a final projection.
1315

1416
### Fixed
1517

Readme.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,23 @@ We would be very interested to hear where you are using the interface or manifol
2929

3030
## Citation
3131

32-
If you use `ManifoldsBase.jl` in your work, please cite the following
32+
If you use `ManifoldsBase.jl` in your work, please cite the following open access article
3333

3434
```biblatex
35-
@online{2106.08777,
36-
Author = {Seth D. Axen and Mateusz Baran and Ronny Bergmann and Krzysztof Rzecki},
37-
Title = {Manifolds.jl: An Extensible Julia Framework for Data Analysis on Manifolds},
38-
Year = {2021},
39-
Eprint = {2106.08777},
40-
Eprinttype = {arXiv},
35+
@article{AxenBaranBergmannRzecki:2023,
36+
author = {Axen, Seth D. and Baran, Mateusz and Bergmann, Ronny and Rzecki, Krzysztof},
37+
articleno = {33},
38+
doi = {10.1145/3618296},
39+
journal = {ACM Transactions on Mathematical Software},
40+
month = {dec},
41+
number = {4},
42+
title = {Manifolds.Jl: An Extensible Julia Framework for Data Analysis on Manifolds},
43+
volume = {49},
44+
year = {2023},
4145
}
4246
```
4347

48+
4449
To refer to a certain version we recommend to also cite for example
4550

4651
```biblatex

docs/make.jl

+26-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22
#
33
#
44

5+
if "--help" ARGS
6+
println(
7+
"""
8+
docs/make.jl
9+
10+
Render the `Manopt.jl` documenation with optinal arguments
11+
12+
Arguments
13+
* `--help` - print this help and exit without rendering the documentation
14+
* `--prettyurls` – toggle the prettyurls part to true (which is otherwise only true on CI)
15+
* `--quarto` – run the Quarto notebooks from the `tutorials/` folder before generating the documentation
16+
this has to be run locally at least once for the `tutorials/*.md` files to exist that are included in
17+
the documentation (see `--exclude-tutorials`) for the alternative.
18+
If they are generated ones they are cached accordingly.
19+
Then you can spare time in the rendering by not passing this argument.
20+
""",
21+
)
22+
exit(0)
23+
end
24+
525
#
626
# (a) if docs is not the current active environment, switch to it
727
# (from https://github.com/JuliaIO/HDF5.jl/pull/1020/) 
@@ -30,18 +50,19 @@ if "--quarto" ∈ ARGS
3050
end
3151
end
3252

33-
using Documenter: DocMeta, HTML, MathJax3, deploydocs, makedocs
53+
using Documenter
3454
using DocumenterCitations
3555
using ManifoldsBase
3656

3757
# (e) ...finally! make docs
3858
bib = CitationBibliography(joinpath(@__DIR__, "src", "references.bib"); style = :alpha)
3959
makedocs(;
4060
# for development, we disable prettyurls
41-
format = HTML(;
42-
mathengine = MathJax3(),
43-
prettyurls = get(ENV, "CI", nothing) == "true",
44-
assets = ["assets/favicon.ico"],
61+
format = Documenter.HTML(;
62+
prettyurls = (get(ENV, "CI", nothing) == "true") || ("--prettyurls" ARGS),
63+
assets = ["assets/favicon.ico", "assets/citations.css"],
64+
size_threshold_warn = 200 * 2^10, # raise slightly from 100 to 200 KiB
65+
size_threshold = 300 * 2^10, # raise slightly 200 to to 300 KiB
4566
),
4667
modules = [ManifoldsBase],
4768
authors = "Seth Axen, Mateusz Baran, Ronny Bergmann, and contributors.",

docs/src/functions.md

+8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ Public=false
5858
Private=true
5959
```
6060

61+
## Approximation Methods
62+
63+
```@autodocs
64+
Modules = [ManifoldsBase]
65+
Pages = ["approximation_methods.jl"]
66+
Order = [:type, :function]
67+
```
68+
6169
## Error Messages
6270

6371
This interface introduces a small set of own error messages.

docs/src/index.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ If you use `ManifoldsBase.jl` in your work, please cite the following paper,
2121
which covers both the basic interface as well as the performance for `Manifolds.jl`.
2222

2323
```biblatex
24-
@online{2106.08777,
25-
Author = {Seth D. Axen and Mateusz Baran and Ronny Bergmann and Krzysztof Rzecki},
26-
Title = {Manifolds.jl: An Extensible Julia Framework for Data Analysis on Manifolds},
27-
Year = {2021},
28-
Eprint = {2106.08777},
29-
Eprinttype = {arXiv},
24+
@article{AxenBaranBergmannRzecki:2023,
25+
AUTHOR = {Axen, Seth D. and Baran, Mateusz and Bergmann, Ronny and Rzecki, Krzysztof},
26+
ARTICLENO = {33},
27+
DOI = {10.1145/3618296},
28+
JOURNAL = {ACM Transactions on Mathematical Software},
29+
MONTH = {dec},
30+
NUMBER = {4},
31+
TITLE = {Manifolds.Jl: An Extensible Julia Framework for Data Analysis on Manifolds},
32+
VOLUME = {49},
33+
YEAR = {2023}
3034
}
3135
```
3236

docs/src/references.bib

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ @book{AbsilMahonySepulchre:2008
1414
TITLE = {Optimization Algorithms on Matrix Manifolds},
1515
YEAR = {2008},
1616
}
17-
17+
@article{AxenBaranBergmannRzecki:2023,
18+
AUTHOR = {Axen, Seth D. and Baran, Mateusz and Bergmann, Ronny and Rzecki, Krzysztof},
19+
ARTICLENO = {33},
20+
DOI = {10.1145/3618296},
21+
JOURNAL = {ACM Transactions on Mathematical Software},
22+
MONTH = {dec},
23+
NUMBER = {4},
24+
TITLE = {Manifolds.Jl: An Extensible Julia Framework for Data Analysis on Manifolds},
25+
VOLUME = {49},
26+
YEAR = {2023}
27+
}
1828
@article{EhlersPiraniSchild:1972,
1929
DOI = {10.1007/s10714-012-1353-4},
2030
YEAR = {1972},

src/ManifoldsBase.jl

+13
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ include("maintypes.jl")
2929
include("numbers.jl")
3030
include("Fiber.jl")
3131
include("bases.jl")
32+
include("approximation_methods.jl")
3233
include("retractions.jl")
3334
include("exp_log_geo.jl")
3435
include("projections.jl")
@@ -1022,6 +1023,17 @@ export AbstractPowerRepresentation,
10221023
NestedPowerRepresentation, NestedReplacingPowerRepresentation
10231024
export ProductManifold
10241025

1026+
# (b) Generic Estimation Types
1027+
1028+
export GeodesicInterpolationWithinRadius,
1029+
CyclicProximalPointEstimation,
1030+
ExtrinsicEstimation,
1031+
GradientDescentEstimation,
1032+
WeiszfeldEstimation,
1033+
AbstractApproximationMethod,
1034+
GeodesicInterpolation
1035+
1036+
10251037
# (b) Retraction Types
10261038
export AbstractRetractionMethod,
10271039
ApproximateInverseRetraction,
@@ -1100,6 +1112,7 @@ export ×,
11001112
change_representer!,
11011113
copy,
11021114
copyto!,
1115+
default_approximation_method,
11031116
default_inverse_retraction_method,
11041117
default_retraction_method,
11051118
default_vector_transport_method,

src/approximation_methods.jl

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
@doc raw"""
2+
AbstractApproximationMethod
3+
4+
Abstract type for defining estimation methods on manifolds.
5+
"""
6+
abstract type AbstractApproximationMethod end
7+
8+
@doc raw"""
9+
GradientDescentEstimation <: AbstractApproximationMethod
10+
11+
Method for estimation using [📖 gradient descent](https://en.wikipedia.org/wiki/Gradient_descent).
12+
"""
13+
struct GradientDescentEstimation <: AbstractApproximationMethod end
14+
15+
@doc raw"""
16+
CyclicProximalPointEstimation <: AbstractApproximationMethod
17+
18+
Method for estimation using the cyclic proximal point technique, which is based on [📖 proximal maps](https://en.wikipedia.org/wiki/Proximal_operator).
19+
"""
20+
struct CyclicProximalPointEstimation <: AbstractApproximationMethod end
21+
22+
@doc raw"""
23+
EfficientEstimator <: AbstractApproximationMethod
24+
25+
Method for estimation in the best possible sense, see [📖 Efficiency (Statictsics)](https://en.wikipedia.org/wiki/Efficiency_(statistics)) for more details.
26+
This can for example be used when computing the usual mean on an Euclidean space, which is the best estimator.
27+
"""
28+
struct EfficientEstimator <: AbstractApproximationMethod end
29+
30+
31+
@doc raw"""
32+
ExtrinsicEstimation{T} <: AbstractApproximationMethod
33+
34+
Method for estimation in the ambient space with a method of type `T` and projecting the result back
35+
to the manifold.
36+
"""
37+
struct ExtrinsicEstimation{T<:AbstractApproximationMethod} <: AbstractApproximationMethod
38+
extrinsic_estimation::T
39+
end
40+
41+
@doc raw"""
42+
WeiszfeldEstimation <: AbstractApproximationMethod
43+
44+
Method for estimation using the Weiszfeld algorithm, compare for example the computation of the
45+
[📖 Geometric median](https://en.wikipedia.org/wiki/Geometric_median).
46+
"""
47+
struct WeiszfeldEstimation <: AbstractApproximationMethod end
48+
49+
@doc raw"""
50+
GeodesicInterpolation <: AbstractApproximationMethod
51+
52+
Method for estimation based on geodesic interpolation.
53+
"""
54+
struct GeodesicInterpolation <: AbstractApproximationMethod end
55+
56+
@doc raw"""
57+
GeodesicInterpolationWithinRadius{T} <: AbstractApproximationMethod
58+
59+
Method for estimation based on geodesic interpolation that is restricted to some `radius`
60+
61+
# Constructor
62+
63+
GeodesicInterpolationWithinRadius(radius::Real)
64+
"""
65+
struct GeodesicInterpolationWithinRadius{T<:Real} <: AbstractApproximationMethod
66+
radius::T
67+
function GeodesicInterpolationWithinRadius(radius::T) where {T<:Real}
68+
radius > 0 && return new{T}(radius)
69+
return throw(
70+
DomainError("The radius must be strictly postive, received $(radius)."),
71+
)
72+
end
73+
end
74+
75+
@doc raw"""
76+
default_approximation_method(M::AbstractManifold, f)
77+
default_approximation_method(M::AbtractManifold, f, T)
78+
79+
Specify a default estimation method for an [`AbstractManifold`](@ref) and a specific function `f`
80+
and optionally as well a type `T` to distinguish different (point or vector) representations on `M`.
81+
82+
By default, all functions `f` call the signature for just a manifold.
83+
The exceptional functions are:
84+
85+
* `retract` and `retract!` which fall back to [`default_retraction_method`](@ref)
86+
* `inverse_retract` and `inverse_retract!` which fall back to [`default_inverse_retraction_method`](@ref)
87+
* any of the vector transport mehods fall back to [`default_vector_transport_method`](@ref)
88+
"""
89+
default_approximation_method(M::AbstractManifold, f)
90+
default_approximation_method(M::AbstractManifold, f, T) = default_approximation_method(M, f)

src/retractions.jl

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
"""
2-
AbstractInverseRetractionMethod
2+
AbstractInverseRetractionMethod <: AbstractApproximationMethod
33
44
Abstract type for methods for inverting a retraction (see [`inverse_retract`](@ref)).
55
"""
6-
abstract type AbstractInverseRetractionMethod end
6+
abstract type AbstractInverseRetractionMethod <: AbstractApproximationMethod end
77

88
"""
9-
AbstractRetractionMethod
9+
AbstractRetractionMethod <: AbstractApproximationMethod
1010
1111
Abstract type for methods for [`retract`](@ref)ing a tangent vector to a manifold.
1212
"""
13-
abstract type AbstractRetractionMethod end
13+
abstract type AbstractRetractionMethod <: AbstractApproximationMethod end
1414

1515
"""
1616
ApproximateInverseRetraction <: AbstractInverseRetractionMethod
@@ -934,3 +934,18 @@ function retract_sasaki! end
934934

935935
Base.show(io::IO, ::CayleyRetraction) = print(io, "CayleyRetraction()")
936936
Base.show(io::IO, ::PadeRetraction{m}) where {m} = print(io, "PadeRetraction($m)")
937+
938+
#
939+
# default estimation methods pass down with and without the point type
940+
function default_approximation_method(M::AbstractManifold, ::typeof(inverse_retract))
941+
return default_inverse_retraction_method(M)
942+
end
943+
function default_approximation_method(M::AbstractManifold, ::typeof(inverse_retract), T)
944+
return default_inverse_retraction_method(M, T)
945+
end
946+
function default_approximation_method(M::AbstractManifold, ::typeof(retract))
947+
return default_retraction_method(M)
948+
end
949+
function default_approximation_method(M::AbstractManifold, ::typeof(retract), T)
950+
return default_retraction_method(M, T)
951+
end

src/vector_transport.jl

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
"""
3-
AbstractVectorTransportMethod
3+
AbstractVectorTransportMethod <: AbstractApproximationMethod
44
55
Abstract type for methods for transporting vectors. Such vector transports are not
66
necessarily linear.
@@ -9,7 +9,7 @@ necessarily linear.
99
1010
[`AbstractLinearVectorTransportMethod`](@ref)
1111
"""
12-
abstract type AbstractVectorTransportMethod end
12+
abstract type AbstractVectorTransportMethod <: AbstractApproximationMethod end
1313

1414
"""
1515
AbstractLinearVectorTransportMethod <: AbstractVectorTransportMethod
@@ -326,6 +326,7 @@ function default_vector_transport_method(M::AbstractManifold, ::Type{T}) where {
326326
return default_vector_transport_method(M)
327327
end
328328

329+
329330
@doc raw"""
330331
pole_ladder(
331332
M,
@@ -1312,3 +1313,34 @@ function vector_transport_to_project!(M::AbstractManifold, Y, p, X, q; kwargs...
13121313
# Note that we have to use embed (not embed!) since we do not have memory to store this embedded value in
13131314
return project!(M, Y, q, embed(M, p, X); kwargs...)
13141315
end
1316+
1317+
# default estimation fallbacks with and without the T
1318+
function default_approximation_method(
1319+
M::AbstractManifold,
1320+
::typeof(vector_transport_direction),
1321+
)
1322+
return default_vector_transport_method(M)
1323+
end
1324+
function default_approximation_method(M::AbstractManifold, ::typeof(vector_transport_along))
1325+
return default_vector_transport_method(M)
1326+
end
1327+
function default_approximation_method(M::AbstractManifold, ::typeof(vector_transport_to))
1328+
return default_vector_transport_method(M)
1329+
end
1330+
function default_approximation_method(
1331+
M::AbstractManifold,
1332+
::typeof(vector_transport_direction),
1333+
T,
1334+
)
1335+
return default_vector_transport_method(M, T)
1336+
end
1337+
function default_approximation_method(
1338+
M::AbstractManifold,
1339+
::typeof(vector_transport_along),
1340+
T,
1341+
)
1342+
return default_vector_transport_method(M, T)
1343+
end
1344+
function default_approximation_method(M::AbstractManifold, ::typeof(vector_transport_to), T)
1345+
return default_vector_transport_method(M, T)
1346+
end

0 commit comments

Comments
 (0)