Skip to content

Commit

Permalink
adjoint_action: more tests
Browse files Browse the repository at this point in the history
more adjoint action methods for CircleGroup
  • Loading branch information
olivierverdier committed Jul 26, 2024
1 parent f1afec9 commit ba2900f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions ext/ManifoldsTestExt/tests_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,19 @@ function test_group(
adjoint_action(G, g_pts[2], adjoint_action(G, inv(G, g_pts[2]), X)),
X,
)
# right adjoint action
Test.@test isapprox(
G,
e,
adjoint_action(G, g_pts[2], adjoint_action(G, g_pts[2], X, RightAction())),
X,
)
if test_mutating
Z = allocate(X)
adjoint_action!(G, Z, g_pts[2], X)
Test.@test isapprox(G, e, Z, adjoint_action(G, g_pts[2], X))
adjoint_action!(G, Z, g_pts[2], X, RightAction())
Test.@test isapprox(G, e, Z, adjoint_action(G, g_pts[2], X, RightAction()))
end

# interaction with Lie bracket
Expand Down
3 changes: 3 additions & 0 deletions src/groups/circle_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ Base.show(io::IO, ::CircleGroup) = print(io, "CircleGroup()")

adjoint_action(::CircleGroup, p, X, ::LeftAction) = X
adjoint_action(::CircleGroup, ::Identity, X, ::LeftAction) = X
adjoint_action(::CircleGroup, p, X, ::RightAction) = X
adjoint_action(::CircleGroup, ::Identity, X, ::RightAction) = X

adjoint_action!(::CircleGroup, Y, p, X, ::LeftAction) = copyto!(Y, X)
adjoint_action!(::CircleGroup, Y, p, X, ::RightAction) = copyto!(Y, X)

function compose(
::MultiplicationGroupTrait,
Expand Down
5 changes: 3 additions & 2 deletions test/groups/product_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using RecursiveArrayTools
end

pts = [ArrayPartition(tp...) for tp in tuple_pts]
X_pts = [ArrayPartition(tuple_v...)]
X_pts = [ArrayPartition(tuple_v...), ArrayPartition(tuple_v...)]

@testset "setindex! and getindex" begin
p1 = pts[1]
Expand All @@ -53,6 +53,7 @@ using RecursiveArrayTools
test_vee_hat_from_identity=true,
test_inv_diff=true,
test_adjoint_inv_diff=true,
test_adjoint_action=true,
)
@test isapprox(
G,
Expand Down Expand Up @@ -94,7 +95,7 @@ using RecursiveArrayTools

@test compose(G, pts[1], Identity(G)) == pts[1]
@test compose(G, Identity(G), pts[1]) == pts[1]
test_group(G, pts, X_pts, X_pts; test_diff=true, test_mutating=false)
test_group(G, pts, X_pts, X_pts; test_diff=true, test_mutating=false, test_adjoint_action=true)
test_manifold(G, pts; is_mutating=false)
@test isapprox(
G,
Expand Down

0 comments on commit ba2900f

Please sign in to comment.