diff --git a/Project.toml b/Project.toml index 847e39b..f79e261 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ManifoldDiff" uuid = "af67fdf4-a580-4b9f-bbec-742ef357defd" authors = ["Seth Axen ", "Mateusz Baran ", "Ronny Bergmann "] -version = "0.3.2" +version = "0.3.3" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -13,7 +13,6 @@ Requires = "ae029012-a4dd-5104-9daa-d747884805df" FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41" FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" -Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e" ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" @@ -21,7 +20,6 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" ManifoldDiffFiniteDiffExt = "FiniteDiff" ManifoldDiffFiniteDifferencesExt = "FiniteDifferences" ManifoldDiffForwardDiffExt = "ForwardDiff" -ManifoldDiffManifoldsExt = "Manifolds" ManifoldDiffReverseDiffExt = "ReverseDiff" ManifoldDiffZygoteExt = "Zygote" diff --git a/ext/ManifoldDiffManifoldsExt.jl b/ext/ManifoldDiffManifoldsExt.jl deleted file mode 100644 index f1b4a93..0000000 --- a/ext/ManifoldDiffManifoldsExt.jl +++ /dev/null @@ -1,168 +0,0 @@ -module ManifoldDiffManifoldsExt - -if isdefined(Base, :get_extension) - using ManifoldDiff - using ManifoldDiff: ProjectorOntoVector, CoprojectorOntoVector, IdentityProjector - using Manifolds -else - # imports need to be relative for Requires.jl-based workflows: - # https://github.com/JuliaArrays/ArrayInterface.jl/pull/387 - using ..ManifoldDiff - using ..ManifoldDiff: ProjectorOntoVector, CoprojectorOntoVector, IdentityProjector - using ..Manifolds -end - -function ManifoldDiff.adjoint_Jacobi_field( - M::ProductManifold, - p::ArrayPartition, - q::ArrayPartition, - t, - X::ArrayPartition, - β::Tβ, -) where {Tβ} - return ArrayPartition( - map( - ManifoldDiff.adjoint_Jacobi_field, - M.manifolds, - submanifold_components(M, p), - submanifold_components(M, q), - ntuple(_ -> t, length(M.manifolds)), - submanifold_components(M, X), - ntuple(_ -> β, length(M.manifolds)), - )..., - ) -end -function ManifoldDiff.adjoint_Jacobi_field!( - M::ProductManifold, - Y, - p, - q, - t, - X, - β::Tβ, -) where {Tβ} - map( - ManifoldDiff.adjoint_Jacobi_field!, - M.manifolds, - submanifold_components(M, Y), - submanifold_components(M, p), - submanifold_components(M, q), - ntuple(_ -> t, length(M.manifolds)), - submanifold_components(M, X), - ntuple(_ -> β, length(M.manifolds)), - ) - return Y -end -function ManifoldDiff.adjoint_Jacobi_field(::Circle{ℝ}, p, q, t, X, β::Tβ) where {Tβ} - return X -end -function ManifoldDiff.adjoint_Jacobi_field( - ::Euclidean{Tuple{}}, - p, - q, - t, - X, - β::Tβ, -) where {Tβ} - return X -end - -function ManifoldDiff.diagonalizing_projectors(M::AbstractSphere{ℝ}, p, X) - X_norm = norm(M, p, X) - X_normed = X / X_norm - return ( - (zero(number_eltype(p)), ProjectorOntoVector(M, p, X_normed)), - (one(number_eltype(p)), CoprojectorOntoVector(M, p, X_normed)), - ) -end - -function ManifoldDiff.diagonalizing_projectors(M::Hyperbolic, p, X) - X_norm = norm(M, p, X) - X_normed = X / X_norm - return ( - (zero(number_eltype(p)), ProjectorOntoVector(M, p, X_normed)), - (-one(number_eltype(p)), CoprojectorOntoVector(M, p, X_normed)), - ) -end - -function ManifoldDiff.diagonalizing_projectors(::Euclidean, p, X) - return ((zero(number_eltype(p)), IdentityProjector()),) -end - -function ManifoldDiff.diagonalizing_projectors(M::Circle{ℝ}, p, X) - sbv = sign(X[]) - proj = ProjectorOntoVector( - M, - p, - Manifolds.StaticArrays.@SVector [sbv == 0 ? one(sbv) : sbv] - ) - return ((zero(number_eltype(p)), proj),) -end - -function ManifoldDiff.jacobi_field( - M::ProductManifold, - p::ArrayPartition, - q::ArrayPartition, - t, - X::ArrayPartition, - β::Tβ, -) where {Tβ} - return ArrayPartition( - map( - ManifoldDiff.jacobi_field, - M.manifolds, - submanifold_components(M, p), - submanifold_components(M, q), - ntuple(_ -> t, length(M.manifolds)), - submanifold_components(M, X), - ntuple(_ -> β, length(M.manifolds)), - )..., - ) -end -function ManifoldDiff.jacobi_field!(M::ProductManifold, Y, p, q, t, X, β::Tβ) where {Tβ} - map( - ManifoldDiff.jacobi_field!, - M.manifolds, - submanifold_components(M, Y), - submanifold_components(M, p), - submanifold_components(M, q), - ntuple(_ -> t, length(M.manifolds)), - submanifold_components(M, X), - ntuple(_ -> β, length(M.manifolds)), - ) - return Y -end -function ManifoldDiff.jacobi_field(::Circle{ℝ}, p, q, t, X, β::Tβ) where {Tβ} - return X -end -function ManifoldDiff.jacobi_field(::Euclidean{Tuple{}}, p, q, t, X, β::Tβ) where {Tβ} - return X -end - -### differentials - -function ManifoldDiff.differential_exp_argument_lie_approx!( - M::AbstractManifold, - Z, - p, - X, - Y; - n = 20, -) - tmp = copy(M, p, Y) - a = -1.0 - zero_vector!(M, Z, p) - for k in 0:n - a *= -1 // (k + 1) - Z .+= a .* tmp - if k < n - copyto!(tmp, lie_bracket(M, X, tmp)) - end - end - q = exp(M, p, X) - translate_diff!(M, Z, q, Identity(M), Z) - return Z -end - - -end diff --git a/src/ManifoldDiff.jl b/src/ManifoldDiff.jl index af2a5e2..4b179ea 100644 --- a/src/ManifoldDiff.jl +++ b/src/ManifoldDiff.jl @@ -190,10 +190,6 @@ function __init__() include("../ext/ManifoldDiffForwardDiffExt.jl") end - @require Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e" begin - include("../ext/ManifoldDiffManifoldsExt.jl") - end - @require ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" begin include("../ext/ManifoldDiffReverseDiffExt.jl") end diff --git a/test/manifold_specializations.jl b/test/manifold_specializations.jl index 951cf32..973d6fc 100644 --- a/test/manifold_specializations.jl +++ b/test/manifold_specializations.jl @@ -4,9 +4,7 @@ using Test using LinearAlgebra using ManifoldDiff: - differential_exp_argument, - differential_exp_argument_lie_approx, - differential_inverse_retract_argument_fd_approx + differential_exp_argument, differential_inverse_retract_argument_fd_approx @testset "Rotations(3)" begin M = Rotations(3) @@ -24,28 +22,6 @@ using ManifoldDiff: ω = [[1.0, 2.0, 3.0], [3.0, 2.0, 1.0], [1.0, 3.0, 2.0]] pts = [exp(M, p, hat(M, p, ωi)) for ωi in ω] Xpts = [hat(M, p, [-1.0, 2.0, 0.5]), hat(M, p, [1.0, 0.0, 0.5])] - - @testset "differentials" begin - q2 = exp(G, pts[1], Xpts[2]) - @test isapprox( - G, - q2, - differential_exp_argument_lie_approx(G, pts[1], Xpts[1], Xpts[2]; n = 0), - Xpts[2], - ) - diff_ref = [ - 0.0 -0.7482721017619345 -0.508151233069837 - 0.7482721017619345 0.0 -0.10783358474129323 - 0.508151233069837 0.10783358474129323 0.0 - ] - @test isapprox( - G, - q2, - differential_exp_argument_lie_approx(G, pts[1], Xpts[1], Xpts[2]), - diff_ref; - atol = 1e-12, - ) - end end @testset "FiniteDifferenceLogDiffArgumentMethod" begin