Skip to content

Commit

Permalink
Fix the last features.
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Jan 19, 2025
1 parent dec3d70 commit ed70aeb
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 8 deletions.
33 changes: 32 additions & 1 deletion src/groups/special_euclidean_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ end
function ManifoldsBase.check_point(G::RightSpecialEuclideanGroup, p; kwargs...)
return _check_point(G, G.manifold[2], G.manifold[1], G.op[2], G.op[1], p; kwargs...)
end
# Resolve ambiguities with identity
function ManifoldsBase.check_point(G::LeftSpecialEuclideanGroup, ::Identity{LeftSemidirectProductGroupOperation}; kwargs...)
return nothing
end
function ManifoldsBase.check_point(G::RightSpecialEuclideanGroup, ::Identity{RightSemidirectProductGroupOperation}; kwargs...)
return nothing
end

function _check_point(
G::SpecialEuclideanGroup{T}, Rotn, Rn, op1, op2, p; kwargs...
Expand Down Expand Up @@ -664,11 +671,35 @@ function ManifoldsBase.log!(
end

function ManifoldsBase.log!(
::SpecialEuclideanGroup, X, ::Identity{<:SpecialEuclideanOperation}, g
::LeftSpecialEuclideanGroup, X, ::Identity{LeftSpecialEuclideanOperation}, g
)
copyto!(X, log(g))
return X
end
function ManifoldsBase.log!(
::RightSpecialEuclideanGroup,
X,
::Identity{RightSpecialEuclideanOperation},
g,
)
copyto!(X, log(g))
return X
end
function ManifoldsBase.log!(
G::LeftSpecialEuclideanGroup,
X,
e::O,
::O,
) where {O<:Identity{LeftSpecialEuclideanOperation}}
zero_vector!(G, e, X)
return X
end
function ManifoldsBase.log!(
G::RightSpecialEuclideanGroup, X, e::O, ::O
) where {O<:Identity{RightSpecialEuclideanOperation}}
zero_vector!(G, e, X)
return X
end

function ManifoldsBase.representation_size(G::SpecialEuclideanGroup)
s = Manifolds.get_parameter(G.manifold[1].size)[1]
Expand Down
39 changes: 33 additions & 6 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -517,28 +517,52 @@ function get_coordinates_lie!(G::LieGroup, c, g, X, N)
end

_doc_get_vector = """
get_vector(G::LieGroup, g, c, B::AbstractBasis)
get_vector(𝔤::LieAlgebra, c, B::AbstractBasis)
get_vector!(G::LieGroup, X, g, c, B::AbstractBasis)
get_vector!(𝔤::LieAlgebra, X, c, B::AbstractBasis)
get_vector(G::LieGroup, g, c, B::AbstractBasis; kwargs...)
get_vector(𝔤::LieAlgebra, c, B::AbstractBasis; kwargs...)
get_vector!(G::LieGroup, X::T, g, c, B::AbstractBasis; kwargs...)
get_vector!(𝔤::LieAlgebra, X::T, c, B::AbstractBasis; kwargs...)
Return the vector corresponding to a set of coefficients in an [`AbstractBasis`](@extref `ManifoldsBase.AbstractBasis`)
of the [`LieAlgebra`](@ref) `𝔤`.
Since all tangent vectors are assumed to be represented in the Lie algebra,
both signatures are equivalent.
The operation can be performed in-place of a tangent vector `X`.
The operation can be performed in-place of a tangent vector `X` of type `::T`.
By default this function requires [`identity_element`](@ref)`(G)` and calls
the corresponding [`get_vector`](@extref ManifoldsBase :jl:function:`ManifoldsBase.get_vectors`) function
of the Riemannian manifold the Lie group is build on.
The inverse operation is [`get_coordinates`](@ref).
# Keyword arguments
* `tangent_vector_type` specify the tangent vector type to use for the allocating variants.
See also [`hat`](@ref)
"""

@doc "$(_doc_get_vector)"
ManifoldsBase.get_vector(G::LieGroup, g, c, B::ManifoldsBase.AbstractBasis)
function ManifoldsBase.get_vector(
G::LieGroup,
g,
c,
B::ManifoldsBase.AbstractBasis;
tangent_vector_type=nothing,
kwargs...,
)
return ManifoldsBase._get_vector(M, p, c, B, tangent_vector_type)
end
# Overwrite layer 2 as well if a basis is provided and if we get nothing
@inline function ManifoldsBase._get_vector(
M::AbstractManifold, p, c, B::DefaultOrthogonalBasis, ::Nothing
)
return get_vector_lie(M, p, c, number_system(B))
end
@inline function ManifoldsBase._get_vector(
M::AbstractManifold, p, c, B::DefaultOrthogonalBasis, T::Type
)
return get_vector_lie(M, p, c, number_system(B), T)
end

@doc "$(_doc_exp_id)"
ManifoldsBase.get_vector!(G::LieGroup, X, g, c, B::ManifoldsBase.AbstractBasis)
Expand Down Expand Up @@ -591,6 +615,9 @@ Technically, `hat` is a specific case of [`get_vector`](@ref) and is implemented
function hat(G::LieGroup{𝔽}, c) where {𝔽}
return get_vector_lie(G, Identity(G), c, 𝔽)
end
function hat(G::LieGroup{𝔽}, c, T::Type) where {𝔽}
return get_vector_lie(G, Identity(G), c, 𝔽, T)
end

# function hat! end
@doc "$(_doc_hat)"
Expand Down
2 changes: 1 addition & 1 deletion test/LieGroupsTestSuite.jl/LieGroupsTestSuite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ function test_hat_vee(
𝔤 = LieAlgebra(G)
if test_hat
c = ismissing(expected_value) ? zeros(manifold_dimension(G)) : expected_value
Y1 = hat(G, c)
Y1 = hat(G, c, typeof(X))
@test is_vector(G, g, Y1)
!ismissing(expected_value) && @test isapprox(𝔤, X, Y1)
if test_mutating
Expand Down

0 comments on commit ed70aeb

Please sign in to comment.