Skip to content

Commit

Permalink
activate more tests that should work
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Jan 17, 2025
1 parent 16e3bec commit e8212db
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 29 deletions.
10 changes: 8 additions & 2 deletions src/Lie_algebra/Lie_algebra_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ function ManifoldsBase.zero_vector(𝔤::LieAlgebra)
# pass to manifold directly
return ManifoldsBase.zero_vector(𝔤.manifold.manifold, identity_element(𝔤.manifold))
end
function ManifoldsBase.zero_vector!(𝔤::LieAlgebra, X)
function ManifoldsBase.zero_vector(𝔤::LieAlgebra, ::T) where {T}
# pass to Lie group
return ManifoldsBase.zero_vector(𝔤.manifold, identity_element(𝔤.manifold, T))
end
function ManifoldsBase.zero_vector!(𝔤::LieAlgebra, X::T) where {T}
# pass to manifold directly
return ManifoldsBase.zero_vector!(𝔤.manifold.manifold, X, identity_element(𝔤.manifold))
return ManifoldsBase.zero_vector!(
𝔤.manifold.manifold, X, identity_element(𝔤.manifold, T)
)
end
25 changes: 13 additions & 12 deletions src/groups/special_euclidean_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ ManifoldsBase.exp(

@doc "$(_doc_exp_SE2_id)"
function ManifoldsBase.exp!(
G::SpecialEuclideanGroup{ManifoldsBase.TypeParameter{Tuple{2}}},
G::SpecialEuclideanGroup{<:ManifoldsBase.TypeParameter{Tuple{2}}},
g,
::Identity{<:SpecialEuclideanOperation},
X,
Expand Down Expand Up @@ -375,15 +375,15 @@ This result can be computed in-place of `g`.
@doc "$(_doc_exp_SE3_id)"
ManifoldsBase.exp(
::SpecialEuclideanGroup{ManifoldsBase.TypeParameter{Tuple{3}}},
::Identity{SpecialEuclideanOperation},
::Identity{<:SpecialEuclideanOperation},
::Any,
)

@doc "$(_doc_exp_SE3_id)"
function ManifoldsBase.exp!(
G::SpecialEuclideanGroup{ManifoldsBase.TypeParameter{Tuple{3}}},
g,
::Identity{SpecialEuclideanOperation},
::Identity{<:SpecialEuclideanOperation},
X,
)
init_constants!(G, g)
Expand All @@ -408,11 +408,12 @@ function ManifoldsBase.exp!(
end

function ManifoldsBase.exp!(
G::SpecialEuclideanGroup,
G::SpecialEuclideanGroup{ManifoldsBase.TypeParameter{Tuple{n}}},
g::AbstractMatrix,
::Identity{SpecialEuclideanOperation},
X::AbstractMatrix,
)
::Identity{<:SpecialEuclideanOperation},
X;
AbstractMatrix,
) where {n}
copyto!(g, exp(X))
return g
end
Expand Down Expand Up @@ -582,15 +583,15 @@ This result can be computed in-place of `g`.
@doc "$(_doc_log_SE2_id)"
ManifoldsBase.log(
::SpecialEuclideanGroup{ManifoldsBase.TypeParameter{Tuple{2}}},
::Identity{SpecialEuclideanOperation},
::Identity{<:SpecialEuclideanOperation},
::Any,
)

@doc "$(_doc_log_SE2_id)"
function ManifoldsBase.log!(
G::SpecialEuclideanGroup{ManifoldsBase.TypeParameter{Tuple{2}}},
X,
::Identity{SpecialEuclideanOperation},
::Identity{<:SpecialEuclideanOperation},
g,
)
init_constants!(LieAlgebra(G), X)
Expand Down Expand Up @@ -637,15 +638,15 @@ This result can be computed in-place of `g`.
@doc "$(_doc_log_SE3_id)"
ManifoldsBase.log(
::SpecialEuclideanGroup{ManifoldsBase.TypeParameter{Tuple{3}}},
::Identity{SpecialEuclideanOperation},
::Identity{<:SpecialEuclideanOperation},
::Any,
)

@doc "$(_doc_log_SE3_id)"
function ManifoldsBase.log!(
G::SpecialEuclideanGroup{ManifoldsBase.TypeParameter{Tuple{3}}},
X,
::Identity{SpecialEuclideanOperation},
::Identity{<:SpecialEuclideanOperation},
g,
)
init_constants!(LieAlgebra(G), X)
Expand All @@ -669,7 +670,7 @@ end
function ManifoldsBase.log!(
::SpecialEuclideanGroup,
X::AbstractMatrix,
::Identity{SpecialEuclideanOperation},
::Identity{<:SpecialEuclideanOperation},
g::AbstractMatrix,
)
copyto!(X, log(g))
Expand Down
23 changes: 18 additions & 5 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,25 @@ Implementing the Lie group exponential function introduces a default implementat
"""

@doc "$_doc_exp"
function ManifoldsBase.exp(G::LieGroup, g, X, t::Number=1)
function ManifoldsBase.exp(G::LieGroup, g, X, t::Number)
h = allocate_result(G, exp, g)
exp!(G, h, g, X, t)
return h
end
function ManifoldsBase.exp(G::LieGroup, g, X)
h = allocate_result(G, exp, g)
exp!(G, h, g, X)
return h
end

@doc "$_doc_exp"
function ManifoldsBase.exp!(G::LieGroup, h, g, X)
exp!(G, h, Identity(G), X)
compose!(G, h, g, h)
return h
end

function ManifoldsBase.exp!(G::LieGroup, h, g, X, t::Number)
exp!(G, h, Identity(G), X, t)
compose!(G, h, g, h)
return h
Expand Down Expand Up @@ -918,8 +929,8 @@ Random.rand(G::LieGroup, T::Type; vector_at=nothing, kwargs...)
function Random.rand(M::LieGroup, T::Type, d::Integer; kwargs...)
return [rand(M, T; kwargs...) for _ in 1:d]
end
function Random.rand(rng::AbstractRNG, M::LieGroup, T::Type, d::Integer; kwargs...)
return [rand(rng, M, T; kwargs...) for _ in 1:d]
function Random.rand(rng::AbstractRNG, G::LieGroup, T::Type, d::Integer; kwargs...)
return [rand(rng, G, T; kwargs...) for _ in 1:d]
end
function Random.rand(G::LieGroup, d::Integer; kwargs...)
return [rand(M; kwargs...) for _ in 1:d]
Expand Down Expand Up @@ -948,12 +959,14 @@ function Random.rand!(G::LieGroup, pX; kwargs...)
return rand!(Random.default_rng(), G, pX; kwargs...)
end

function Random.rand!(rng::AbstractRNG, G::LieGroup, pX; vector_at=nothing, kwargs...)
function Random.rand!(
rng::AbstractRNG, G::LieGroup, pX::T; vector_at=nothing, kwargs...
) where {T}
M = base_manifold(G)
if vector_at === nothing # for points -> pass to manifold
rand!(rng, M, pX, kwargs...)
else # for tangent vectors -> materialize identity, pass to tangent space there.
rand!(rng, M, pX; vector_at=identity_element(G), kwargs...)
rand!(rng, M, pX; vector_at=identity_element(G, T), kwargs...)
end
end

Expand Down
20 changes: 10 additions & 10 deletions test/groups/test_special_euclidean_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using LieGroupsTestSuite
@testset "Special Euclidean" begin
G = SpecialEuclideanGroup(2)
g1 = 1 / sqrt(2) .* [1.0 1.0 sqrt(2); -1.0 1.0 0.0; 0.0 0.0 sqrt(2)]
g2 = 1 / sqrt(2) .* [0.0 -1.0 0.0; 1.0 0.0 1.0; 0.0 0.0 1.0]
g2 = [0.0 -1.0 0.0; 1.0 0.0 1.0; 0.0 0.0 1.0]
g3 = [1.0 0.0 1.0; 0.0 1.0 1.0; 0.0 0.0 1.0]
X1 = [0.0 -0.23 0.0; 0.23 0.0 1.0; 0.0 0.0 0.0]
X2 = [0.0 0.30 1.0; -0.20 0.0 1.0; 0.0 0.0 0.0]
Expand All @@ -30,9 +30,9 @@ using LieGroupsTestSuite
inv,
# inv_left_compose,
# inv_right_compose,
# is_identity,
is_identity,
# lie_bracket,
# log,
log,
rand,
show,
vee,
Expand Down Expand Up @@ -72,10 +72,10 @@ using LieGroupsTestSuite
inv,
# inv_left_compose,
# inv_right_compose,
# is_identity,
is_identity,
# lie_bracket,
# log,
# rand, TODO: introduce rand(G, T)
log,
rand,
show,
vee,
],
Expand Down Expand Up @@ -106,7 +106,7 @@ using LieGroupsTestSuite
:Functions => [
# adjoint,
compose,
# conjugate,
conjugate,
# diff_inv,
# diff_left_compose,
# diff_right_compose,
Expand All @@ -116,10 +116,10 @@ using LieGroupsTestSuite
inv,
# inv_left_compose,
# inv_right_compose,
# is_identity,
is_identity,
# lie_bracket,
# log,
# rand, TODO: introduce rand(G, T)
log,
rand,
show,
vee,
],
Expand Down

0 comments on commit e8212db

Please sign in to comment.