-
Notifications
You must be signed in to change notification settings - Fork 56
/
translation_action.jl
87 lines (69 loc) · 2.33 KB
/
translation_action.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@doc raw"""
TranslationAction(
M::AbstractManifold,
Rn::TranslationGroup,
AD::ActionDirection = LeftForwardAction(),
)
Space of actions of the [`TranslationGroup`](@ref) $\mathrm{T}(n)$ on a Euclidean-like
manifold `M`.
The left and right actions are equivalent.
"""
struct TranslationAction{TM<:AbstractManifold,TRn<:TranslationGroup,TAD<:ActionDirection} <:
AbstractGroupAction{TAD}
manifold::TM
Rn::TRn
end
function TranslationAction(
M::AbstractManifold,
Rn::TranslationGroup,
::TAD=LeftForwardAction(),
) where {TAD<:ActionDirection}
return TranslationAction{typeof(M),typeof(Rn),TAD}(M, Rn)
end
function Base.show(io::IO, A::TranslationAction)
return print(io, "TranslationAction($(A.manifold), $(A.Rn), $(direction(A)))")
end
base_group(A::TranslationAction) = A.Rn
group_manifold(A::TranslationAction) = A.manifold
function switch_direction(
A::TranslationAction{TM,TSO,TAD},
::LeftRightSwitch=LeftRightSwitch(),
) where {TM<:AbstractManifold,TSO<:TranslationGroup,TAD<:ActionDirection}
return TranslationAction(A.manifold, A.Rn, switch_direction(TAD(), LeftRightSwitch()))
end
adjoint_apply_diff_group(::TranslationAction, a, X, p) = X
function adjoint_apply_diff_group!(A::TranslationAction, Y, a, X, p)
copyto!(A.manifold, Y, p, X)
return Y
end
apply(::TranslationAction, a, p) = p + a
apply!(::TranslationAction, q, a, p) = (q .= p .+ a)
function apply!(A::TranslationAction, q, e::Identity{AdditionOperation}, p)
return copyto!(A.manifold, q, p)
end
inverse_apply(::TranslationAction, a, p) = p - a
inverse_apply!(::TranslationAction, q, a, p) = (q .= p .- a)
function inverse_apply!(A::TranslationAction, q, e::Identity{AdditionOperation}, p)
return copyto!(A.manifold, q, p)
end
apply_diff(::TranslationAction, a, p, X) = X
function apply_diff!(A::TranslationAction, Y, a, p, X)
return copyto!(A.manifold, Y, p, X)
end
function apply_diff_group(::TranslationAction{N,F,LeftForwardAction}, a, X, p) where {N,F}
return X
end
function apply_diff_group!(
A::TranslationAction{N,F,LeftForwardAction},
Y,
a,
X,
p,
) where {N,F}
copyto!(A.manifold, Y, p, X)
return Y
end
inverse_apply_diff(::TranslationAction, a, p, X) = X
function inverse_apply_diff!(A::TranslationAction, Y, a, p, X)
return copyto!(A.manifold, Y, p, X)
end