Skip to content

Commit

Permalink
Implement the last three functions, dispatch for Lie algebra not yet …
Browse files Browse the repository at this point in the history
…fully working.
  • Loading branch information
kellertuer committed Nov 28, 2024
1 parent 9e0fde3 commit bf0b181
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 6 deletions.
46 changes: 46 additions & 0 deletions src/groups/power_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,21 @@ function ManifoldsBase.exp!(
return h
end

function hat!(
PoG::LieGroup{𝔽,Op,M}, X, c
) where {𝔽,Op<:PowerGroupOperation,M<:ManifoldsBase.AbstractPowerManifold}
PM = PoG.manifold
rep_size = representation_size(PM.manifold)
dim = manifold_dimension(PM.manifold)
v_iter = 1
G = LieGroup(PM.manifold, PoG.op.op)
for i in ManifoldsBase.get_iterator(PM)
hat!(G, ManifoldsBase._write(PM, rep_size, X, i), c[v_iter:(v_iter + dim - 1)])
v_iter += dim
end
return X
end

function identity_element!(
PoG::LieGroup{𝔽,Op,M}, e
) where {𝔽,Op<:PowerGroupOperation,M<:ManifoldsBase.AbstractPowerManifold}
Expand Down Expand Up @@ -241,6 +256,22 @@ function inv!(
return h
end

function lie_bracket!(
PoA::LieAlgebra{𝔽,<:LieGroup{𝔽,Op,M}}, Z, X, Y
) where {𝔽,Op<:PowerGroupOperation,M<:ManifoldsBase.AbstractPowerManifold}
PM = PoA.manifold.manifold
rep_size = representation_size(PM)
𝔤 = LieAlgebra(LieGroup(PM.manifold, PoA.manifold.op.op))
for i in ManifoldsBase.get_iterator(PM)
lie_bracket!(
𝔤,
ManifoldsBase._write(PM, rep_size, Z, i),
ManifoldsBase._read(PM, rep_size, X, i),
ManifoldsBase._read(PM, rep_size, Y, i),
)
end
end

function ManifoldsBase.log!(
PoG::LieGroup{𝔽,Op,M}, X, ::Identity{Op}, g
) where {𝔽,Op<:PowerGroupOperation,M<:ManifoldsBase.AbstractPowerManifold}
Expand Down Expand Up @@ -268,3 +299,18 @@ function Base.show(
size = Manifolds.get_parameter(G.manifold.size)
return print(io, "PowerLieGroup($L, $(join(size, ", ")))")
end

function vee!(
PoG::LieGroup{𝔽,Op,M}, c, X
) where {𝔽,Op<:PowerGroupOperation,M<:ManifoldsBase.AbstractPowerManifold}
PM = PoG.manifold
rep_size = representation_size(PM.manifold)
dim = manifold_dimension(PM.manifold)
G = LieGroup(PM.manifold, PoG.op.op)
v_iter = 1
for i in ManifoldsBase.get_iterator(PM)
vee!(G, view(c, v_iter:(v_iter + dim - 1)), ManifoldsBase._read(PM, rep_size, X, i))
v_iter += dim
end
return c
end
42 changes: 42 additions & 0 deletions src/groups/product_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,21 @@ function ManifoldsBase.exp!(
return h
end

function hat!(
PrG::LieGroup{𝔽,Op,M}, X, c
) where {𝔽,Op<:ProductGroupOperation,M<:ManifoldsBase.ProductManifold}
PrM = PrG.manifold
dims = map(manifold_dimension, PrM.manifolds)
@assert length(c) == sum(dims)
dim_ranges = ManifoldsBase._get_dim_ranges(dims)
Prc = map(dr -> (@inbounds view(c, dr)), dim_ranges)
ts = ManifoldsBase.ziptuples(PM.manifolds, submanifold_components(PM, X), Prc)
map(ts) do t
return hat!(t...)
end
return X
end

function identity_element!(
PrG::LieGroup{𝔽,Op,M}, e
) where {𝔽,Op<:ProductGroupOperation,M<:ManifoldsBase.ProductManifold}
Expand Down Expand Up @@ -228,6 +243,20 @@ function inv!(
return h
end

function lie_bracket!(
PrA::LieAlgebra{𝔽,<:LieGroup{𝔽,Op,M}}, Z, X, Y
) where {𝔽,Op<:ProductGroupOperation,M<:ManifoldsBase.ProductManifold}
PrM = PrA.manifold.manifold
map(
lie_bracket!,
LieAlgebra.(LieGroup.(PrM.manifolds, PrA.op.operations)),
submanifold_components(PrM, Z),
submanifold_components(PrM, X),
submanifold_components(PrM, Y),
)
return Z
end

function ManifoldsBase.log!(
PrG::LieGroup{𝔽,Op,M}, X, ::Identity{Op}, g
) where {𝔽,Op<:ProductGroupOperation,M<:ManifoldsBase.ProductManifold}
Expand All @@ -249,3 +278,16 @@ function Base.show(
ops = G.op.operations
return print(io, "ProductLieGroup($(join(PrM, " × ")), $(join(ops, " × ")))")
end

function vee!(
PrG::LieGroup{𝔽,Op,M}, c, X
) where {𝔽,Op<:ProductGroupOperation,M<:ManifoldsBase.ProductManifold}
PrM = PrG.manifold
map(
vee!,
LieGroup.(PrM.manifolds, PrG.op.operations),
submanifold_components(PrM, c),
submanifold_components(PrM, X),
)
return X
end
6 changes: 3 additions & 3 deletions test/groups/test_power_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ using LieGroupsTestSuite
diff_left_compose,
diff_right_compose,
exp,
# hat,
hat,
inv,
inv_left_compose,
inv_right_compose,
is_identity,
# lie_bracket,
lie_bracket,
log,
rand,
# vee,
vee,
],
)
expectations2 = Dict(
Expand Down
6 changes: 3 additions & 3 deletions test/groups/test_product_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ using LieGroupsTestSuite
diff_left_compose,
diff_right_compose,
exp,
# hat,
hat,
inv,
inv_left_compose,
inv_right_compose,
is_identity,
# lie_bracket,
lie_bracket,
log,
rand,
show,
#vee,
vee,
],
)
expectations = Dict(
Expand Down

0 comments on commit bf0b181

Please sign in to comment.