Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend support for SpecialEuclidean, fiber bundles, optionally static sizes #642

Merged
merged 91 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
fe4f1f7
Add action of SE(n) on R^n
mateuszbaran Jul 10, 2023
6ed9547
some docs
mateuszbaran Jul 11, 2023
de9fd2c
formatting
mateuszbaran Jul 11, 2023
41b7bcf
Merge branch 'master' into mbaran/special-euclidean-revisited
mateuszbaran Jul 11, 2023
2dff357
expand tutorial
mateuszbaran Jul 12, 2023
1fa3ac7
Start describing dynamics
mateuszbaran Jul 12, 2023
c4f5df3
fiber bundles pt. 1
mateuszbaran Jul 26, 2023
950a74e
fix product manifold
mateuszbaran Jul 26, 2023
de7d281
direct sum bundle
mateuszbaran Jul 27, 2023
b4cf7ac
optionally static sizes: part 1
mateuszbaran Aug 18, 2023
54799cb
optionally static sizes: part 2
mateuszbaran Aug 18, 2023
0f0be00
Merge branch 'master' into mbaran/special-euclidean-revisited
mateuszbaran Sep 3, 2023
0f8e431
a few fixes
mateuszbaran Sep 3, 2023
f8961e7
bugfixing
mateuszbaran Sep 5, 2023
b399539
Stiefel, SPD, minor fixes
mateuszbaran Sep 6, 2023
7ee384a
remove `ProductRepr`, bugfixing, optional static reworking
mateuszbaran Sep 6, 2023
0b781ac
finish conversion to optionally static
mateuszbaran Sep 7, 2023
85549d8
updating Hyperbolic
mateuszbaran Sep 7, 2023
0ca6811
Merge branch 'master' into mbaran/special-euclidean-revisited
mateuszbaran Sep 7, 2023
83c0272
fix CI issue
mateuszbaran Sep 7, 2023
60aed68
use type parameter in a couple of places
mateuszbaran Sep 8, 2023
9472f7b
updates
mateuszbaran Sep 8, 2023
19cf391
more tests and some fixes
mateuszbaran Sep 11, 2023
2ad761c
Update NEWS.md
mateuszbaran Sep 11, 2023
8e441e5
address review regarding optionally static size
mateuszbaran Sep 12, 2023
999d0de
remove get_mn
mateuszbaran Sep 12, 2023
49fa34d
add some comments, remove old code
mateuszbaran Sep 12, 2023
52f8724
bump tolerance
mateuszbaran Sep 13, 2023
73aadae
fix test
mateuszbaran Sep 13, 2023
59d98e0
improve code coverage
mateuszbaran Sep 14, 2023
40bf7e5
Merge remote-tracking branch 'origin/mbaran/special-euclidean-revisit…
mateuszbaran Sep 14, 2023
8e8bc40
fix Orthogonal, _get_parameter for SE(N), improved NEWS
mateuszbaran Sep 14, 2023
89265a1
a few tests
mateuszbaran Sep 18, 2023
43051eb
tests
mateuszbaran Sep 18, 2023
48dd288
more tests
mateuszbaran Sep 19, 2023
ca31836
mostly docs and structure
mateuszbaran Sep 19, 2023
26cee70
Merge branch 'master' into mbaran/special-euclidean-revisited
mateuszbaran Sep 25, 2023
c90e9a3
generalize a couple of methods
mateuszbaran Sep 25, 2023
bfe4fe0
remove some less-developed parts
mateuszbaran Sep 25, 2023
3f04abd
reworking action direction and invariant metrics
mateuszbaran Sep 26, 2023
d79ed6c
Merge branch 'master' into mbaran/special-euclidean-revisited
mateuszbaran Sep 28, 2023
a326c63
adapting to moving some meta-manifolds to ManifoldsBase
mateuszbaran Oct 5, 2023
7632169
some updates
mateuszbaran Oct 10, 2023
baa79b1
Merge branch 'master' into mbaran/special-euclidean-revisited
mateuszbaran Oct 11, 2023
561b0b5
some updates
mateuszbaran Oct 11, 2023
b2dfeee
fixes
mateuszbaran Oct 11, 2023
32c8e96
fixes
mateuszbaran Oct 13, 2023
3a1e4d6
fixes
mateuszbaran Oct 14, 2023
0b99b8e
adapt power manifold
mateuszbaran Oct 14, 2023
600f46f
Adapt to recent changes in ManifoldsBase 0.15 WIP
mateuszbaran Oct 15, 2023
17b5a4a
minor improvements
mateuszbaran Oct 15, 2023
d6091f8
minor adaptation of (inverse) retractions
mateuszbaran Oct 16, 2023
0a1ecfc
adapt to exp/retract unification
mateuszbaran Oct 16, 2023
7cfde4e
Mostly update to error in is_point/is_vector changes
mateuszbaran Oct 16, 2023
f26d329
replaced a bit too eagerly
mateuszbaran Oct 16, 2023
8e97d94
fix a few more errors
mateuszbaran Oct 16, 2023
3910dcd
remove deprecations, update NEWS
mateuszbaran Oct 17, 2023
e3fd23a
Fix errors that changed in type.
kellertuer Oct 17, 2023
d39ca6e
Adapt a few more error tests.
kellertuer Oct 17, 2023
b640264
Fix a. few more errors.
kellertuer Oct 17, 2023
eb3f920
Update test/groups/general_unitary_groups.jl
kellertuer Oct 17, 2023
2629646
some fixes
mateuszbaran Oct 17, 2023
09cdd06
More fixes.
kellertuer Oct 17, 2023
4e2980e
Merge branch 'mbaran/special-euclidean-revisited' of github.com:Julia…
kellertuer Oct 17, 2023
7317d20
Fix the remaining failing tests for group
kellertuer Oct 17, 2023
3732499
===
mateuszbaran Oct 17, 2023
30c1597
Merge branch 'master' into mbaran/special-euclidean-revisited
mateuszbaran Oct 18, 2023
63f5364
Merge remote-tracking branch 'origin/mbaran/special-euclidean-revisit…
mateuszbaran Oct 18, 2023
cb78c99
formatting
mateuszbaran Oct 18, 2023
0f52313
update some docs
mateuszbaran Oct 18, 2023
6d2c04e
better docs for group actions
mateuszbaran Oct 21, 2023
96c3ed5
bump versions
mateuszbaran Oct 21, 2023
5174442
bump docs compat
mateuszbaran Oct 21, 2023
7399d05
randomly trying to fix docs?
mateuszbaran Oct 22, 2023
7acb501
f
mateuszbaran Oct 22, 2023
9da6dbf
try this
mateuszbaran Oct 22, 2023
7660641
try this, try that...
mateuszbaran Oct 22, 2023
f6162eb
fix docs
mateuszbaran Oct 22, 2023
c11f82f
fixing again
mateuszbaran Oct 22, 2023
0d38cf3
Maybe fix?
mateuszbaran Oct 22, 2023
2cc48b8
cut some redundant tests
mateuszbaran Oct 22, 2023
34396b3
cut repeated tests of ProductManifold (they exist in ManifoldsBase.jl)
mateuszbaran Oct 22, 2023
9ea0d83
a bit of testing
mateuszbaran Oct 22, 2023
a86aa3f
not sure what these are for
mateuszbaran Oct 22, 2023
d98622a
a bit of fiber bundle cleanup
mateuszbaran Oct 22, 2023
db2c0c3
improve coverage a little
mateuszbaran Oct 23, 2023
7481720
some docs
mateuszbaran Oct 23, 2023
697df39
docs improvements; split group actions to a separate page
mateuszbaran Oct 23, 2023
da0d4b3
Apply suggestions from code review
mateuszbaran Oct 23, 2023
489b2f7
add changelog to docs
mateuszbaran Oct 23, 2023
34fcb0a
fix link
mateuszbaran Oct 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ makedocs(
"🚀 Get Started with `Manifolds.jl`" => "tutorials/getstarted.md",
"work in charts" => "tutorials/working-in-charts.md",
"perform Hand gesture analysis" => "tutorials/hand-gestures.md",
"do rigid body dynamics with geometry" => "tutorials/rigid-body-dynamics.md",
],
"Manifolds" => [
"Basic manifolds" => [
Expand Down
8 changes: 8 additions & 0 deletions docs/src/manifolds/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ Pages = ["groups/translation_action.jl"]
Order = [:type, :function]
```

### Rotation-translation action (special Euclidean)

```@autodocs
Modules = [Manifolds]
Pages = ["groups/rotation_translation_action.jl"]
Order = [:type, :function]
```

## Metrics on groups

Lie groups by default typically forward all metric-related operations like exponential or logarithmic map to the underlying manifold, for example [`SpecialOrthogonal`](@ref) uses methods for [`Rotations`](@ref) (which is, incidentally, bi-invariant), or [`SpecialEuclidean`](@ref) uses product metric of the translation and rotation parts (which is not invariant under group operation).
Expand Down
4 changes: 2 additions & 2 deletions ext/ManifoldsTestExt/tests_group.jl
Original file line number Diff line number Diff line change
Expand Up @@ -741,10 +741,10 @@ function test_action(

eX = allocate(X)
Test.@test apply_diff!(A, eX, e, m, X) === eX
Test.@test isapprox(G, m, eX, X; atol=atol)
kellertuer marked this conversation as resolved.
Show resolved Hide resolved
Test.@test isapprox(M, m, eX, X; atol=atol)
eX = allocate(X)
Test.@test inverse_apply_diff!(A, eX, e, m, X) === eX
Test.@test isapprox(G, m, eX, X; atol=atol)
Test.@test isapprox(M, m, eX, X; atol=atol)
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions src/Manifolds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ include("groups/rotation_action.jl")

include("groups/special_euclidean.jl")

include("groups/rotation_translation_action.jl")

# final utilities
include("trait_recursion_breaking.jl")

Expand Down Expand Up @@ -880,6 +882,7 @@ export AbstractGroupAction,
RightForwardAction,
RightInvariantMetric,
RotationAction,
RotationTranslationAction,
SemidirectProductGroup,
SpecialEuclidean,
SpecialLinear,
Expand Down
2 changes: 1 addition & 1 deletion src/groups/rotation_action.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const RotationActionOnVector{N,F,TAD} = RotationAction{
<:Union{Euclidean{Tuple{N},F},TranslationGroup{Tuple{N},F}},
SpecialOrthogonal{N},
TAD,
}
} where {TAD<:ActionDirection}

base_group(A::RotationAction) = A.SOn

Expand Down
313 changes: 313 additions & 0 deletions src/groups/rotation_translation_action.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,313 @@
@doc raw"""
RotationTranslationAction(
M::AbstractManifold,
SOn::SpecialEuclidean,
AD::ActionDirection = LeftForwardAction(),
)

Space of actions of the [`SpecialEuclidean`](@ref) group $\mathrm{SE}(n)$ on a
Euclidean-like manifold `M` of dimension `n`.

Left forward action corresponds to active transformations while right forward actions
can be identified with passive transformations for a particular choice of a basis.
"""
struct RotationTranslationAction{
TM<:AbstractManifold,
TSE<:SpecialEuclidean,
TAD<:ActionDirection,
} <: AbstractGroupAction{TAD}
manifold::TM
SEn::TSE
end

kellertuer marked this conversation as resolved.
Show resolved Hide resolved
function RotationTranslationAction(
M::AbstractManifold,
SEn::SpecialEuclidean,
::TAD=LeftForwardAction(),
) where {TAD<:ActionDirection}
return RotationTranslationAction{typeof(M),typeof(SEn),TAD}(M, SEn)
end

function Base.show(io::IO, A::RotationTranslationAction)
return print(io, "RotationTranslationAction($(A.manifold), $(A.SEn), $(direction(A)))")
end

const RotationTranslationActionOnVector{N,F,TAD} = RotationTranslationAction{
<:Union{Euclidean{Tuple{N},F},TranslationGroup{Tuple{N},F}},
SpecialEuclidean{N},
TAD,
} where {TAD<:ActionDirection}

base_group(A::RotationTranslationAction) = A.SEn

group_manifold(A::RotationTranslationAction) = A.manifold

function switch_direction(
A::RotationTranslationAction{TM,TSO,TAD},
::LeftRightSwitch=LeftRightSwitch(),
) where {TM<:AbstractManifold,TSO<:SpecialEuclidean,TAD<:ActionDirection}
return RotationTranslationAction(
A.manifold,
A.SEn,
switch_direction(TAD(), LeftRightSwitch()),
)
end

function apply(
::RotationTranslationActionOnVector{N,F,LeftForwardAction},
a::ArrayPartition,
p,
) where {N,F}
return a.x[2] * p + a.x[1]
end
function apply(
::RotationTranslationActionOnVector{N,F,LeftForwardAction},
a::SpecialEuclideanIdentity{N},
p,
) where {N,F}
return p
end
function apply(
::RotationTranslationActionOnVector{N,F,RightForwardAction},
a::ArrayPartition,
p,
) where {N,F}
return a.x[2] \ (p - a.x[1])
end
function apply(
::RotationTranslationActionOnVector{N,F,RightForwardAction},
a::SpecialEuclideanIdentity{N},
p,
) where {N,F}
return p
end

function apply!(
::RotationTranslationActionOnVector{N,F,LeftForwardAction},
q,
a::ArrayPartition,
p,
) where {N,F}
mul!(q, a.x[2], p)
q .+= a.x[1]
return q
end
function apply!(
::RotationTranslationActionOnVector{N,F,LeftForwardAction},
q,
a::SpecialEuclideanIdentity{N},
p,
) where {N,F}
copyto!(q, p)
return q
end

function inverse_apply(
::RotationTranslationActionOnVector{N,F,LeftForwardAction},
a::ArrayPartition,
p,
) where {N,F}
return a.x[2] \ (p - a.x[1])
end
function inverse_apply(
::RotationTranslationActionOnVector{N,F,RightForwardAction},
a::ArrayPartition,
p,
) where {N,F}
return a.x[2] * p + a.x[1]
end

function apply_diff(
::RotationTranslationActionOnVector{N,F,LeftForwardAction},
a::ArrayPartition,
p,
X,
) where {N,F}
return a.x[2] * X
end
function apply_diff(
::RotationTranslationActionOnVector{N,F,LeftForwardAction},
::SpecialEuclideanIdentity{N},
p,
X,
) where {N,F}
return X
end
function apply_diff(
::RotationTranslationActionOnVector{N,F,RightForwardAction},
a::ArrayPartition,
p,
X,
) where {N,F}
return a.x[2] \ X
end
function apply_diff(
::RotationTranslationActionOnVector{N,F,RightForwardAction},
a::SpecialEuclideanIdentity{N},
p,
X,
) where {N,F}
return X
end

function apply_diff!(
::RotationTranslationActionOnVector{N,F,LeftForwardAction},
Y,
a::ArrayPartition,
p,
X,
) where {N,F}
return mul!(Y, a.x[2], X)
end
function apply_diff!(
::RotationTranslationActionOnVector{N,F,LeftForwardAction},
Y,
a::SpecialEuclideanIdentity{N},
p,
X,
) where {N,F}
return copyto!(Y, X)
end
function apply_diff!(
::RotationTranslationActionOnVector{N,F,RightForwardAction},
Y,
a::ArrayPartition,
p,
X,
) where {N,F}
Y .= a.x[2] \ X
return Y
end
function apply_diff!(
::RotationTranslationActionOnVector{N,F,RightForwardAction},
Y,
a::SpecialEuclideanIdentity{N},
p,
X,
) where {N,F}
return copyto!(Y, X)
end

function apply_diff_group(
::RotationTranslationActionOnVector{N,F,LeftForwardAction},
::SpecialEuclideanIdentity{N},
X,
p,
) where {N,F}
return X.x[2] * p
end

function apply_diff_group!(
::RotationTranslationActionOnVector{N,F,LeftForwardAction},
Y,
::SpecialEuclideanIdentity{N},
X::ArrayPartition,
p,
) where {N,F}
Y .= X.x[2] * p
return Y
end

function inverse_apply_diff(
::RotationTranslationActionOnVector{N,F,LeftForwardAction},
a::ArrayPartition,
p,
X,
) where {N,F}
return a.x[2] \ X
end
function inverse_apply_diff(
::RotationTranslationActionOnVector{N,F,RightForwardAction},
a::ArrayPartition,
p,
X,
) where {N,F}
return a.x[2] * X
end

###

@doc raw"""
kellertuer marked this conversation as resolved.
Show resolved Hide resolved
ColumnwiseSpecialEuclideanAction{
TM<:AbstractManifold,
TSE<:SpecialEuclidean,
TAD<:ActionDirection,
} <: AbstractGroupAction{TAD}

Action of the special Euclidean group [`SpecialEuclidean`](@ref)
of type `SE` columns of points on a matrix manifold `M`.

# Constructor

ColumnwiseSpecialEuclideanAction(
M::AbstractManifold,
SE::SpecialEuclidean,
AD::ActionDirection = LeftForwardAction(),
)
"""
struct ColumnwiseSpecialEuclideanAction{
TM<:AbstractManifold,
TSE<:SpecialEuclidean,
TAD<:ActionDirection,
} <: AbstractGroupAction{TAD}
manifold::TM
SE::TSE
end

function ColumnwiseSpecialEuclideanAction(
M::AbstractManifold,
SE::SpecialEuclidean,
::TAD=LeftForwardAction(),
) where {TAD<:ActionDirection}
return ColumnwiseSpecialEuclideanAction{typeof(M),typeof(SE),TAD}(M, SE)
end

const LeftColumnwiseSpecialEuclideanAction{TM<:AbstractManifold,TSE<:SpecialEuclidean} =
ColumnwiseSpecialEuclideanAction{TM,TSE,LeftForwardAction}

function apply(::LeftColumnwiseSpecialEuclideanAction, a::ArrayPartition, p)
return a.x[2] * p .+ a.x[1]
end
function apply(::LeftColumnwiseSpecialEuclideanAction, ::SpecialEuclideanIdentity, p)
return p
end

function apply!(::LeftColumnwiseSpecialEuclideanAction, q, a::ArrayPartition, p)
map((qrow, prow) -> mul!(qrow, a.x[2], prow), eachcol(q), eachcol(p))
q .+= a.x[1]
return q
end
function apply!(::LeftColumnwiseSpecialEuclideanAction, q, a::SpecialEuclideanIdentity, p)
copyto!(q, p)
return q
end

base_group(A::LeftColumnwiseSpecialEuclideanAction) = A.SE

group_manifold(A::LeftColumnwiseSpecialEuclideanAction) = A.manifold

function inverse_apply(::LeftColumnwiseSpecialEuclideanAction, a::ArrayPartition, p)
return a.x[2] \ (p .- a.x[1])
end

@doc raw"""
optimal_alignment(A::LeftColumnwiseSpecialEuclideanAction, p, q)

Compute optimal alignment of `p` to `q` under the forward left [`ColumnwiseSpecialEuclideanAction`](@ref).
The algorithm, in sequence, computes optimal translation and optimal rotation
"""
function optimal_alignment(
A::LeftColumnwiseSpecialEuclideanAction{<:AbstractManifold,<:SpecialEuclidean{N}},
p,
q,
) where {N}
tr_opt = mean(q; dims=1) - mean(p; dims=1)
p_moved = p + tr_opt

Ostar = optimal_alignment(
ColumnwiseMultiplicationAction(A.manifold, SpecialOrthogonal(N)),
p_moved,
q,
)
return ArrayPartition(tr_opt, Ostar)
end
Loading