Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbaran committed Oct 27, 2023
1 parent 6a941f8 commit 8abdea7
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/groups/group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ function inverse_translate_diff(
conv::ActionDirectionAndSide,
)
BG = base_group(G)
return translate_diff(BG, inv(BG, p), q, inv_diff(BG, p, X), conv)
return translate_diff(BG, inv(BG, p), q, X, conv)
end

@trait_function inverse_translate_diff!(
Expand All @@ -939,7 +939,7 @@ function inverse_translate_diff!(
conv::ActionDirectionAndSide,
)
BG = base_group(G)
return translate_diff!(BG, Y, inv(BG, p), q, inv_diff(BG, p, X), conv)
return translate_diff!(BG, Y, inv(BG, p), q, X, conv)
end

@doc raw"""
Expand Down
40 changes: 38 additions & 2 deletions src/groups/group_operation_action.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,48 @@ end

function adjoint_apply_diff_group(A::GroupOperationAction, a, X, p)
G = base_group(A)
return inverse_translate_diff(G, a, p, X, reverse_direction_and_side(A))
if direction_and_side(A) === LeftForwardAction() ||

Check warning on line 68 in src/groups/group_operation_action.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/group_operation_action.jl#L68

Added line #L68 was not covered by tests
direction_and_side(A) === RightBackwardAction()
return inverse_translate_diff(

Check warning on line 70 in src/groups/group_operation_action.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/group_operation_action.jl#L70

Added line #L70 was not covered by tests
G,
a,
p,
X,
(direction(A), switch_side(action_side(A))),
)
else
return inverse_translate_diff(

Check warning on line 78 in src/groups/group_operation_action.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/group_operation_action.jl#L78

Added line #L78 was not covered by tests
G,
p,
a,
inv_diff(G, a, X),
(direction(A), switch_side(action_side(A))),
)
end
end

function adjoint_apply_diff_group!(A::GroupOperationAction, Y, a, X, p)
G = base_group(A)
return inverse_translate_diff!(G, Y, a, p, X, reverse_direction_and_side(A))
if direction_and_side(A) === LeftForwardAction() ||

Check warning on line 90 in src/groups/group_operation_action.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/group_operation_action.jl#L90

Added line #L90 was not covered by tests
direction_and_side(A) === RightBackwardAction()
return inverse_translate_diff!(

Check warning on line 92 in src/groups/group_operation_action.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/group_operation_action.jl#L92

Added line #L92 was not covered by tests
G,
Y,
a,
p,
X,
(direction(A), switch_side(action_side(A))),
)
else
return inverse_translate_diff!(

Check warning on line 101 in src/groups/group_operation_action.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/group_operation_action.jl#L101

Added line #L101 was not covered by tests
G,
Y,
p,
a,
inv_diff(G, a, X),
(direction(A), switch_side(action_side(A))),
)
end
end

apply(A::GroupOperationAction, a, p) = translate(A.group, a, p, direction_and_side(A))
Expand Down
13 changes: 12 additions & 1 deletion src/groups/multiplication_operation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Base.:\(p, ::Identity{MultiplicationOperation}) = inv(p)
Base.:\(::Identity{MultiplicationOperation}, p) = p
Base.:\(e::Identity{MultiplicationOperation}, ::Identity{MultiplicationOperation}) = e

Base.inv(e::Identity{MultiplicationOperation}) = e

Check warning on line 26 in src/groups/multiplication_operation.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/multiplication_operation.jl#L26

Added line #L26 was not covered by tests

LinearAlgebra.det(::Identity{MultiplicationOperation}) = true
LinearAlgebra.adjoint(e::Identity{MultiplicationOperation}) = e

Expand Down Expand Up @@ -132,7 +134,16 @@ The formula reads ``-p^{-1}Xp^{-1}``.
"""
function inv_diff(::MultiplicationGroupTrait, G::AbstractDecoratorManifold, p, X)
p_inv = inv(p)
return -p_inv * X * p_inv
return -(p_inv * X * p_inv)

Check warning on line 137 in src/groups/multiplication_operation.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/multiplication_operation.jl#L135-L137

Added lines #L135 - L137 were not covered by tests
end
function inv_diff(

Check warning on line 139 in src/groups/multiplication_operation.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/multiplication_operation.jl#L139

Added line #L139 was not covered by tests
::MultiplicationGroupTrait,
G::AbstractDecoratorManifold,
p::AbstractArray{<:Number,0},
X::AbstractArray{<:Number,0},
)
p_inv = inv(p[])
return -(p_inv * X * p_inv)

Check warning on line 146 in src/groups/multiplication_operation.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/multiplication_operation.jl#L145-L146

Added lines #L145 - L146 were not covered by tests
end
function inv_diff!(::MultiplicationGroupTrait, G::AbstractDecoratorManifold, Y, p, X)
p_inv = inv(p)
Expand Down
14 changes: 14 additions & 0 deletions src/groups/power_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ function inv!(
return q
end

function inv_diff!(G::PowerGroup, Y, p, X)
GM = G.manifold
rep_size = representation_size(GM.manifold)
for i in get_iterator(GM)
inv_diff!(

Check warning on line 135 in src/groups/power_group.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/power_group.jl#L131-L135

Added lines #L131 - L135 were not covered by tests
GM,
_write(GM, rep_size, Y, i),
_read(GM, rep_size, p, i),
_read(GM, rep_size, X, i),
)
end
return Y

Check warning on line 142 in src/groups/power_group.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/power_group.jl#L141-L142

Added lines #L141 - L142 were not covered by tests
end

# lower level methods are added instead of top level ones to not have to deal
# with `Identity` disambiguation

Expand Down
12 changes: 12 additions & 0 deletions src/groups/product_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ function inv!(G::ProductGroup, q, p)
end
inv!(::ProductGroup, q::Identity{ProductOperation}, ::Identity{ProductOperation}) = q

function inv_diff!(G::ProductGroup, Y, p, X)
M = G.manifold
map(

Check warning on line 107 in src/groups/product_group.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/product_group.jl#L105-L107

Added lines #L105 - L107 were not covered by tests
inv_diff!,
M.manifolds,
submanifold_components(G, Y),
submanifold_components(G, p),
submanifold_components(G, X),
)
return Y

Check warning on line 114 in src/groups/product_group.jl

View check run for this annotation

Codecov / codecov/patch

src/groups/product_group.jl#L114

Added line #L114 was not covered by tests
end

_compose(G::ProductGroup, p, q) = _compose(G.manifold, p, q)
function _compose(M::ProductManifold, p::ArrayPartition, q::ArrayPartition)
return ArrayPartition(
Expand Down

0 comments on commit 8abdea7

Please sign in to comment.