Skip to content

Commit

Permalink
Merge branch 'kellertuer/SOn-and-SEn' of github.com:JuliaManifolds/Li…
Browse files Browse the repository at this point in the history
…eGroups.jl into kellertuer/SOn-and-SEn
  • Loading branch information
kellertuer committed Jan 17, 2025
2 parents 05d9af0 + 9a157d6 commit f80da46
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/groups/special_euclidean_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ struct SpecialEuclideanMatrixPoint{T} <: AbstractLieGroupPoint
value::T
end

function ManifoldsBase.allocate_on(
M::SpecialEuclideanGroup, ::Type{SpecialEuclideanMatrixPoint}
)
return SpecialEuclideanMatrixPoint(Matrix(undef, representation_size(M)...))
end

"""
SpecialEuclideanMatrixTVector <: AbstractLieGroupPoint
Expand Down
33 changes: 31 additions & 2 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,31 @@ Random.rand(::LieGroup; kwargs...)

# New in LIeGroups – maybe move to ManifoldsBase at some point
@doc "$(_doc_rand)"
function Random.rand(G::LieGroup, T::Type; vector_at=nothing, kwargs...)
# TODO conitnue here and allocate the right thing.
Random.rand(G::LieGroup, T::Type; vector_at=nothing, kwargs...)

function Random.rand(M::AbstractManifold, T::Type, d::Integer; kwargs...)
return [rand(M, T; kwargs...) for _ in 1:d]
end
function Random.rand(rng::AbstractRNG, M::AbstractManifold, T::Type, d::Integer; kwargs...)
return [rand(rng, M, T; kwargs...) for _ in 1:d]
end
function Random.rand(M::AbstractManifold, T; vector_at=nothing, kwargs...)
if vector_at === nothing
pX = allocate_on(M, T)
else
pX = allocate_on(M, TangentSpaceType(), T)
end
rand!(M, pX; vector_at=vector_at, kwargs...)
return pX
end
function Random.rand(rng::AbstractRNG, M::AbstractManifold, T; vector_at=nothing, kwargs...)
if vector_at === nothing
pX = allocate_on(M, T)
else
pX = allocate_on(M, TangentSpaceType(), T)
end
rand!(rng, M, pX; vector_at=vector_at, kwargs...)
return pX
end

@doc "$(_doc_rand)"
Expand Down Expand Up @@ -997,6 +1020,12 @@ end

#
# Allocation hints - mainly pass-through, especially for power manifolds

ManifoldsBase.allocate_on(G::LieGroup, T::Type) = ManifoldsBase.allocate_on(G.manifold, T)
function ManifoldsBase.allocate_on(M::LieGroup, T::Type{<:AbstractArray})
return ManifoldsBase.allocate_on(M.manifold, T)
end

function ManifoldsBase.allocate_result(
G::LieGroup,
f::Union{typeof(compose),typeof(inv),typeof(conjugate),typeof(exp)},
Expand Down

0 comments on commit f80da46

Please sign in to comment.