Skip to content

Commit

Permalink
Code Coverage II.
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Aug 24, 2023
1 parent 313001e commit cbbd0cf
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/manifolds/Sphere.jl
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ The formula is due to [AbsilMahonyTrumpf:2013](@cite) given by
Weingarten(::Sphere, p, X, V)

function Weingarten!(::Sphere, Y, p, X, V)
Y .= -X * p'V
Y .= -X * (p'V)
return Y

Check warning on line 538 in src/manifolds/Sphere.jl

View check run for this annotation

Codecov / codecov/patch

src/manifolds/Sphere.jl#L536-L538

Added lines #L536 - L538 were not covered by tests
end

Expand Down
14 changes: 7 additions & 7 deletions src/manifolds/StiefelCanonicalMetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ function inverse_retract!(
end

@doc raw"""
Y = riemannian_Hessian(M::MetricManifold{ℝ, Stiefel{n,k,ℝ}, CanonicalMetric}, p, G, H, X)
riemannian_Hessian!(M::MetricManifold{ℝ, Stiefel{n,k,ℝ}, CanonicalMetric}, Y, p, G, H, X)
Y = riemannian_Hessian(M::MetricManifold{ℝ, Stiefel{n,k}, CanonicalMetric}, p, G, H, X)
riemannian_Hessian!(M::MetricManifold{ℝ, Stiefel{n,k}, CanonicalMetric}, Y, p, G, H, X)
Compute the Riemannian Hessian ``\operatorname{Hess} f(p)[X]`` given the
Euclidean gradient ``∇ f(\tilde p)`` in `G` and the Euclidean Hessian ``∇^2 f(\tilde p)[\tilde X]`` in `H`,
where ``\tilde p, \tilde X`` are the representations of ``p,X`` in the embedding,.
Here, we adopt Eq. (5.6) [Nguyen:2023](@cite), for the [`CanonicalMetric`](https://juliamanifolds.github.io/ManifoldsBase.jl/stable/manifolds.html#ManifoldsBase.EuclideanMetric)
Here, we adopt Eq. (5.6) [Nguyen:2023](@cite), for the [`CanonicalMetric`](@ref)
``α_0=1, α_1=\frac{1}{2}`` in their formula. The formula reads
```math
Expand All @@ -211,21 +211,21 @@ where ``P = I-pp^{\mathrm{H}}``.
Compared to Eq. (5.6) we have ``α_0 = 1`` and ``α_1 = \frac{1}{2}``.
"""
riemannian_Hessian(
M::MetricManifold{,Stiefel{n,k,},CanonicalMetric},
M::MetricManifold{𝔽,Stiefel{n,k,𝔽},CanonicalMetric},
p,
G,
H,
X,
) where {n,k}
) where {n,k,𝔽}

function riemannian_Hessian!(

Check warning on line 221 in src/manifolds/StiefelCanonicalMetric.jl

View check run for this annotation

Codecov / codecov/patch

src/manifolds/StiefelCanonicalMetric.jl#L221

Added line #L221 was not covered by tests
::MetricManifold{,Stiefel{n,k,},CanonicalMetric},
M::MetricManifold{𝔽,Stiefel{n,k,𝔽},CanonicalMetric},
Y,
p,
G,
H,
X,
) where {n,k}
) where {n,k,𝔽}
project!(

Check warning on line 229 in src/manifolds/StiefelCanonicalMetric.jl

View check run for this annotation

Codecov / codecov/patch

src/manifolds/StiefelCanonicalMetric.jl#L229

Added line #L229 was not covered by tests
M,
Y,
Expand Down
8 changes: 8 additions & 0 deletions test/manifolds/sphere.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,12 @@ using ManifoldsBase: TFVector
@test dpX[2][1] == 1.0
@test dpX[2][2].X == normalize(X)
end
@testset "Weingarten" begin
M = Sphere(2)
p = [1.0, 0.0, 0.0]
X = [0.0, 2.0, 0.0]
V = [0.3, 0.0, 0.0]
Y = -X * (p'V)
@test Weingarten(M, p, X, V) == Y
end
end
2 changes: 2 additions & 0 deletions test/manifolds/stiefel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ include("../utils.jl")
@test inner(M3, p, X, Y) == 0
@test inner(M3, p, X, 2 * X + 3 * Y) == 2 * inner(M3, p, X, X)
@test norm(M3, p, X) distance(M3, p, q)
Z = [0.0 0.0; 0.0 0.0; -1.0 -1.0]
@test riemannian_Hessian(M3, p, Y, Z, X) == [0.0 0.5; -0.5 0.0; -1.0 -1.0]
# check on a higher dimensional manifold, that the iterations are actually used
M4 = MetricManifold(Stiefel(10, 2), CanonicalMetric())
p = Matrix{Float64}(I, 10, 2)
Expand Down
9 changes: 9 additions & 0 deletions test/manifolds/vector_bundle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,13 @@ struct TestVectorSpaceType <: VectorSpaceType end
@test is_flat(M)
@test injectivity_radius(M) == Inf
end

@testset "Weingarten Map" begin
p0 = [1.0, 0.0, 0.0]
M = TangentSpaceAtPoint(Sphere(2), p0)
p = [0.0, 1.0, 1.0]
X = [0.0, 1.0, 0.0]
N = [1.0, 0.0, 0.0]
@test Weingarten(M, p, X, V) == zero_vector(M, p)
end
end

0 comments on commit cbbd0cf

Please sign in to comment.