Skip to content

Commit 1aa2f11

Browse files
authored
Fix diff_group_apply (#73)
* Fix diff_group_apply * fix ref name * fixes and tests * fix test * add missing method
1 parent e65f47b commit 1aa2f11

File tree

10 files changed

+78
-11
lines changed

10 files changed

+78
-11
lines changed

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable Changes to the Julia package `LieGroups.jl` will be documented in th
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.6] 2025-10-10
9+
10+
### Fixed
11+
12+
* `diff_group_apply` has corrected documentation and works with `g` equal to `Identity`.
13+
814
## [0.1.5] 2025-10-09
915

1016
### Changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LieGroups"
22
uuid = "6774de46-80ba-43f8-ba42-e41071ccfc5f"
33
authors = ["Seth Axen <[email protected]>", "Mateusz Baran <[email protected]>", "Ronny Bergmann <[email protected]>", "Yueh-Hua Tu", "Olivier Verdier <[email protected]>"]
4-
version = "0.1.5"
4+
version = "0.1.6"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/group_actions/columnwise_action.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,13 @@ function apply!(a::GroupAction{ColumnwiseGroupAction{LeftMultiplicationGroupActi
2222
map((qcol, pcol) -> apply!(b, qcol, g, pcol), eachcol(q), eachcol(p))
2323
return q
2424
end
25+
26+
function diff_group_apply!(
27+
::GroupAction{ColumnwiseGroupAction{LeftMultiplicationGroupAction}},
28+
Y,
29+
::Identity{MatrixMultiplicationGroupOperation},
30+
p,
31+
X,
32+
)
33+
return Base.mightalias(Y, X) ? Y .= X * p : mul!(Y, X, p)
34+
end

src/group_actions/group_action_interface.jl

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,19 +277,39 @@ function diff_apply! end
277277
@doc "$(_doc_diff_apply)"
278278
diff_apply!(A::GroupAction, q, g, p)
279279

280-
_doc_diff_group_apply = """
280+
_doc_diff_group_apply = raw"""
281281
diff_group_apply(A::GroupAction, g, p, X)
282282
diff_group_apply!(A::GroupAction, Y, g, p, X)
283283
284-
Compute the differential ``$(_math(:d))_{$(_tex(:Cal, "G"))} σ_g(p): $(_math(:𝔤))$(_math(:𝔤))``,
285-
where we use the short hand notation ``σ_p(g) = σ(g,p)`` for a left action,
286-
and for a right action ``τ_p(g) = τ(g,p)``.
284+
285+
Compute the value of differential of action [`GroupAction`](@ref) `A` on vector `X`,
286+
where element `g` is acting on `p`, with respect to the group element.
287+
288+
Let ``\mathcal G`` be the group acting on manifold ``\mathcal M`` by the action `A`.
289+
The action is of element ``g ∈ \mathcal G`` on a point ``p ∈ \mathcal M``.
290+
The differential transforms vector `X` from the tangent space at `a ∈ \mathcal G`,
291+
``X ∈ T_a \mathcal G`` into a tangent space of the manifold ``\mathcal M``.
292+
When action on element `p` is written as ``\mathrm{d}τ^p``, with the specified left or right
293+
convention, the differential transforms vectors
294+
295+
````math
296+
(\mathrm{d}τ^p) : T_{a} \mathcal G → T_{τ_a p} \mathcal M
297+
````
298+
299+
# See also
300+
301+
[`apply`](@ref), [`diff_apply`](@ref)
287302
"""
288303

289304
function diff_group_apply end
290305
@doc "$(_doc_diff_group_apply)"
291306
function diff_group_apply(A::GroupAction, g, p, X)
292-
Y = allocate_result(base_manifold(A), apply, g, X)
307+
Y = allocate_result(base_manifold(A), diff_group_apply, g, X)
308+
diff_group_apply!(A, Y, g, p, X)
309+
return Y
310+
end
311+
function diff_group_apply(A::GroupAction, g::Identity, p, X)
312+
Y = allocate_on(A.manifold, TangentSpaceType())
293313
diff_group_apply!(A, Y, g, p, X)
294314
return Y
295315
end

src/group_actions/multiplication_action.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ end
2626
function diff_apply!(::GroupAction{LeftMultiplicationGroupAction}, Y, g, p, X)
2727
return Base.mightalias(Y, X) ? Y .= g * X : mul!(Y, g, X)
2828
end
29+
=#
2930

30-
function diff_group_apply!(::GroupAction{LeftMultiplicationGroupAction}, Y, g, p, X)
31+
function diff_group_apply!(::GroupAction{LeftMultiplicationGroupAction}, Y, ::Identity{MatrixMultiplicationGroupOperation}, p, X)
3132
return Base.mightalias(Y, X) ? Y .= X * p : mul!(Y, X, p)
3233
end
33-
=#

test/LieGroupsTestSuite.jl/LieGroupsTestSuite.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ function test_diff_group_apply(
339339
@test isapprox(𝔤, Y1, Y3)
340340
end
341341
end
342+
e = Identity(G)
343+
@test is_vector(G, e, diff_group_apply(A, e, p, X))
342344
!ismissing(expected) && @test isapprox(𝔤, Y1, expected)
343345
end
344346
end

test/actions/test_columnwise_action.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using LieGroupsTestSuite
77

88
@testset "Columnwise Actions" begin
99
G = SpecialOrthogonalGroup(3)
10-
M = Euclidean(3)
10+
M = Euclidean(3, 3)
1111
cga = ColumnwiseGroupAction(LeftMultiplicationGroupAction())
1212
a = GroupAction(cga, G, M)
1313
s = 1 / sqrt(2)
@@ -17,5 +17,6 @@ using LieGroupsTestSuite
1717
@test apply(a, g, p) gp
1818
q = similar(p)
1919
apply!(a, q, g, p)
20-
20+
X = [0.0 -3.0 2.0; 3.0 0.0 -1.0; -2.0 1.0 0.0]
21+
@test diff_group_apply(a, Identity(G), p, X) X * p
2122
end
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using LieGroups, Test
2+
using Manifolds: Euclidean
3+
4+
s = joinpath(@__DIR__, "..", "LieGroupsTestSuite.jl")
5+
!(s in LOAD_PATH) && (push!(LOAD_PATH, s))
6+
using LieGroupsTestSuite
7+
8+
@testset "Multiplication Action" begin
9+
G = SpecialOrthogonalGroup(3)
10+
M = Euclidean(3)
11+
a = LeftMultiplicationGroupAction()
12+
A = GroupAction(a, G, M)
13+
14+
g = [0.7620105424968724 -0.01728550575563964 0.6473338739896082; -0.3990906109981697 0.7746993466910932 0.4904769173462713; -0.5099672708485612 -0.6320934531595508 0.583430586390622]
15+
p = [4.0, 5.0, 6.0]
16+
gp = g * p
17+
@test apply(A, g, p) gp
18+
q = similar(p)
19+
apply!(A, q, g, p)
20+
@test q gp
21+
22+
X = [0.0 -3.0 2.0; 3.0 0.0 -1.0; -2.0 1.0 0.0]
23+
Z = similar(p)
24+
diff_group_apply!(A, Z, Identity(G), p, X)
25+
@test Z X * p
26+
@test diff_group_apply(A, Identity(G), p, X) X * p
27+
end

test/actions/test_rowwise_action.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using LieGroupsTestSuite
77

88
@testset "Rowwise Actions" begin
99
G = SpecialOrthogonalGroup(3)
10-
M = Euclidean(3)
10+
M = Euclidean(3, 3)
1111
cga = RowwiseGroupAction(LeftMultiplicationGroupAction())
1212
a = GroupAction(cga, G, M)
1313
s = 1 / sqrt(2)

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ end
2525
include_test("actions/test_action_interface.jl")
2626
include_test("actions/test_addition_action.jl")
2727
include_test("actions/test_operation_action.jl")
28+
include_test("actions/test_multiplication_action.jl")
2829
include_test("actions/test_rotation_around_axis_action.jl")
2930
include_test("actions/test_columnwise_action.jl")
3031
include_test("actions/test_rowwise_action.jl")

0 commit comments

Comments
 (0)