Skip to content

Commit

Permalink
Fix a few copy paste errors and a test for Lie brackets.
Browse files Browse the repository at this point in the history
  • Loading branch information
kellertuer committed Oct 16, 2024
1 parent 764cb4f commit d06b491
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/group_operations/addition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function diff_right_compose!(G::LieGroup{𝔽,AdditionGroupOperation}, Y, g, h,
end

function lie_bracket!(
𝔤::LieAlgebra{𝔽,LieGroup{𝔽,AdditionGroupOperation}}, Z, X, Y
𝔤::LieAlgebra{𝔽,<:LieGroup{𝔽,AdditionGroupOperation}}, Z, X, Y
) where {𝔽}
return zero_vector!(𝔤, Z)
end
Expand Down
52 changes: 43 additions & 9 deletions test/LieGroupsTestSuite.jl/LieGroupsTestSuite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ function test_diff_inv(G::LieGroup, g, X; expected_value=missing)
Y1 = diff_inv(G, g, X)
Y2 = copy(𝔤, X)
Y2 = diff_inv!(G, Y2, g, X)
@test isapprox(LieAlgebra(G), Y1, Y2)
@test isapprox(𝔤, Y1, Y2)
if !ismissing(expected_value)
@test isapprox(LieAlgebra(G), Y1, expected_value)
@test isapprox(𝔤, Y1, expected_value)
end
end
end
Expand All @@ -161,7 +161,7 @@ function test_diff_left_compose(G::LieGroup, g, h, X; expected_value=missing)
𝔤 = LieAlgebra(G)
Y1 = diff_left_compose(G, g, h, X)
Y2 = copy(𝔤, X)
Y2 = diff_left_compose!(G, Y2, g, h, X)
diff_left_compose!(G, Y2, g, h, X)
@test isapprox(LieAlgebra(G), Y1, Y2)
if !ismissing(expected_value)
@test isapprox(LieAlgebra(G), Y1, expected_value)
Expand All @@ -179,14 +179,14 @@ Test functionality of `diff_right_compose`.
if not provided, only consistency between the allocating and the in-place variant is checked.
"""
function test_diff_right_compose(G::LieGroup, g, h, X; expected_value=missing)
@testset "diff_inv" begin
@testset "diff_right_compose" begin
𝔤 = LieAlgebra(G)
Y1 = diff_left_compose(G, g, h, X)
Y1 = diff_right_compose(G, g, h, X)
Y2 = copy(𝔤, X)
Y2 = diff_left_compose!(G, Y2, g, h, X)
@test isapprox(LieAlgebra(G), Y1, Y2)
diff_right_compose!(G, Y2, g, h, X)
@test isapprox(𝔤, Y1, Y2)
if !ismissing(expected_value)
@test isapprox(LieAlgebra(G), Y1, expected_value)
@test isapprox(𝔤, Y1, expected_value)
end
end
end
Expand Down Expand Up @@ -300,6 +300,31 @@ function test_exp_log(G::LieGroup, g, h, X; test_exp=true, test_log=true)
return nothing
end

#
#
# --- L
"""
test_lie_bracket(G::LieGroup, X, Y; expected_value=missing)
Test functionality of `lie_bracket`.
# Keyword arguments
* `expected_value=missing`: the result of the lie bracket
if not provided, only consistency between the allocating and the in-place variant is checked.
"""
function test_lie_bracket(G::LieGroup, X, Y; expected_value=missing)
@testset "lie_bracket" begin
𝔤 = LieAlgebra(G)
Z1 = lie_bracket(𝔤, X, Y)
Z2 = copy(𝔤, X)
lie_bracket!(𝔤, Z2, X, Y)
@test isapprox(𝔤, Z1, Z2)
if !ismissing(expected_value)
@test isapprox(𝔤, Z1, expected_value)
end
end
end

#
#
# --- S
Expand Down Expand Up @@ -393,7 +418,7 @@ function test_LieGroup(G::LieGroup, properties::Dict, expectations::Dict=Dict())

if (diff_right_compose in functions)
v = get(expectations, :diff_right_compose, missing)
test_diff_left_compose(G, points[1], points[2], vectors[1]; expected_value=v)
test_diff_right_compose(G, points[1], points[2], vectors[1]; expected_value=v)
end

#
Expand All @@ -409,6 +434,15 @@ function test_LieGroup(G::LieGroup, properties::Dict, expectations::Dict=Dict())
test_log=(log in functions),
)
end

#
#
# --- L
if (lie_bracket in functions)
v = get(expectations, :lie_bracket, missing)
test_lie_bracket(G, vectors[1], vectors[2]; expected_value=v)
end

#
#
# --- S
Expand Down
2 changes: 2 additions & 0 deletions test/groups/test_translation_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ begin
identity_element,
inv,
is_identity,
lie_bracket,
log,
show,
],
Expand All @@ -33,6 +34,7 @@ begin
:diff_inv => -X1,
:diff_left_compose => X1,
:diff_right_compose => X1,
:lie_bracket => zero(X1),
)
test_LieGroup(G, properties, expectations)
end

0 comments on commit d06b491

Please sign in to comment.