-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kellertuer/steifel-canonical-metric' of github.com:Juli…
…aManifolds/Manifolds.jl into kellertuer/steifel-canonical-metric
- Loading branch information
Showing
22 changed files
with
1,361 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "Manifolds" | ||
uuid = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e" | ||
authors = ["Seth Axen <[email protected]>", "Mateusz Baran <[email protected]>", "Ronny Bergmann <[email protected]>", "Antoine Levitt <[email protected]>"] | ||
version = "0.4.17" | ||
version = "0.4.19" | ||
|
||
[deps] | ||
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" | ||
|
@@ -48,6 +48,7 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" | |
Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44" | ||
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19" | ||
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" | ||
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56" | ||
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" | ||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" | ||
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee" | ||
|
@@ -59,4 +60,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | |
VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92" | ||
|
||
[targets] | ||
test = ["Test", "Colors", "DoubleFloats", "FiniteDiff", "ForwardDiff", "Gtk", "ImageIO", "ImageMagick", "OrdinaryDiffEq", "Plots", "PyPlot", "Quaternions", "QuartzImageIO", "RecipesBase", "ReverseDiff", "VisualRegressionTests"] | ||
test = ["Test", "Colors", "DoubleFloats", "FiniteDiff", "ForwardDiff", "Gtk", "ImageIO", "ImageMagick", "OrdinaryDiffEq", "NLsolve", "Plots", "PyPlot", "Quaternions", "QuartzImageIO", "RecipesBase", "ReverseDiff", "VisualRegressionTests"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
""" | ||
ApproximateInverseRetraction <: AbstractInverseRetractionMethod | ||
An abstract type for representing approximate inverse retraction methods. | ||
""" | ||
abstract type ApproximateInverseRetraction <: AbstractInverseRetractionMethod end | ||
|
||
""" | ||
NLsolveInverseRetraction{T<:AbstractRetractionMethod,TV,TK} <: | ||
ApproximateInverseRetraction | ||
An inverse retraction method for approximating the inverse of a retraction using `NLsolve`. | ||
# Constructor | ||
NLsolveInverseRetraction( | ||
method::AbstractRetractionMethod[, X0]; | ||
project_tangent=false, | ||
project_point=false, | ||
nlsolve_kwargs..., | ||
) | ||
Constructs an approximate inverse retraction for the retraction `method` with initial guess | ||
`X0`, defaulting to the zero vector. If `project_tangent` is `true`, then the tangent | ||
vector is projected before the retraction using `project`. If `project_point` is `true`, | ||
then the resulting point is projected after the retraction. `nlsolve_kwargs` are keyword | ||
arguments passed to `NLsolve.nlsolve`. | ||
""" | ||
struct NLsolveInverseRetraction{TR<:AbstractRetractionMethod,TV,TK} <: | ||
ApproximateInverseRetraction | ||
retraction::TR | ||
X0::TV | ||
project_tangent::Bool | ||
project_point::Bool | ||
nlsolve_kwargs::TK | ||
function NLsolveInverseRetraction(m, X0, project_point, project_tangent, nlsolve_kwargs) | ||
isdefined(Manifolds, :NLsolve) || | ||
@warn "To use NLsolveInverseRetraction, NLsolve must be loaded using `using NLsolve`." | ||
return new{typeof(m),typeof(X0),typeof(nlsolve_kwargs)}( | ||
m, | ||
X0, | ||
project_point, | ||
project_tangent, | ||
nlsolve_kwargs, | ||
) | ||
end | ||
end | ||
function NLsolveInverseRetraction( | ||
m, | ||
X0=nothing; | ||
project_tangent::Bool=false, | ||
project_point::Bool=false, | ||
nlsolve_kwargs..., | ||
) | ||
return NLsolveInverseRetraction(m, X0, project_point, project_tangent, nlsolve_kwargs) | ||
end | ||
|
||
@decorator_transparent_signature inverse_retract( | ||
M::AbstractDecoratorManifold, | ||
p, | ||
q, | ||
m::NLsolveInverseRetraction, | ||
) | ||
|
||
@decorator_transparent_signature inverse_retract!( | ||
M::AbstractDecoratorManifold, | ||
X, | ||
p, | ||
q, | ||
m::NLsolveInverseRetraction, | ||
) | ||
|
||
@doc raw""" | ||
inverse_retract(M, p, q method::NLsolveInverseRetraction; kwargs...) | ||
Approximate the inverse of the retraction specified by `method.retraction` from `p` with | ||
respect to `q` on the [`Manifold`](@ref) `M` using NLsolve. This inverse retraction is | ||
not guaranteed to succeed and probably will not unless `q` is close to `p` and the initial | ||
guess `X0` is close. | ||
If the solver fails to converge, an [`OutOfInjectivityRadiusError`](@ref) is raised. | ||
See [`NLsolveInverseRetraction`](@ref) for configurable parameters. | ||
""" | ||
inverse_retract(::Manifold, p, q, ::NLsolveInverseRetraction; kwargs...) | ||
|
||
function inverse_retract!(M::Manifold, X, p, q, method::NLsolveInverseRetraction; kwargs...) | ||
X0 = method.X0 === nothing ? zero_tangent_vector(M, p) : method.X0 | ||
res = _inverse_retract_nlsolve( | ||
M, | ||
p, | ||
q, | ||
method.retraction, | ||
X0, | ||
method.project_tangent, | ||
method.project_point, | ||
method.nlsolve_kwargs; | ||
kwargs..., | ||
) | ||
if !res.f_converged | ||
@debug res | ||
throw(OutOfInjectivityRadiusError()) | ||
end | ||
return copyto!(X, res.zero) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.