-
Notifications
You must be signed in to change notification settings - Fork 56
/
GroupManifold.jl
108 lines (95 loc) · 2.87 KB
/
GroupManifold.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
"""
GroupManifold{𝔽,M<:AbstractManifold{𝔽},O<:AbstractGroupOperation} <: AbstractDecoratorManifold{𝔽}
Decorator for a smooth manifold that equips the manifold with a group operation, thus making
it a Lie group. See [`IsGroupManifold`](@ref) for more details.
Group manifolds by default forward metric-related operations to the wrapped manifold.
# Constructor
GroupManifold(manifold, op)
"""
struct GroupManifold{𝔽,M<:AbstractManifold{𝔽},O<:AbstractGroupOperation} <:
AbstractDecoratorManifold{𝔽}
manifold::M
op::O
end
@inline function active_traits(f, M::GroupManifold, args...)
return merge_traits(
IsGroupManifold(M.op),
active_traits(f, M.manifold, args...),
IsExplicitDecorator(),
)
end
@inline function active_traits(f, ::AbstractRNG, M::GroupManifold, args...)
return merge_traits(
IsGroupManifold(M.op),
active_traits(f, M.manifold, args...),
IsExplicitDecorator(),
)
end
decorated_manifold(G::GroupManifold) = G.manifold
(op::AbstractGroupOperation)(M::AbstractManifold) = GroupManifold(M, op)
function (::Type{T})(M::AbstractManifold) where {T<:AbstractGroupOperation}
return GroupManifold(M, T())
end
function inverse_retract(
::TraitList{<:IsGroupManifold},
G::GroupManifold,
p,
q,
method::GroupLogarithmicInverseRetraction,
)
conv = direction_and_side(method)
pinvq = inverse_translate(G, p, q, conv)
Xₑ = log_lie(G, pinvq)
return translate_diff(G, p, Identity(G), Xₑ, conv)
end
function inverse_retract!(
::TraitList{<:IsGroupManifold},
G::GroupManifold,
X,
p,
q,
method::GroupLogarithmicInverseRetraction,
)
conv = direction_and_side(method)
pinvq = inverse_translate(G, p, q, conv)
Xₑ = log_lie(G, pinvq)
return translate_diff!(G, X, p, Identity(G), Xₑ, conv)
end
function is_point(
::TraitList{<:IsGroupManifold},
G::GroupManifold,
e::Identity;
error::Symbol=:none,
kwargs...,
)
ie = is_identity(G, e; kwargs...)
if !ie
s = "The provided identity is not a point on $G."
(error === :error) && throw(DomainError(e, s))
(error === :info) && @info s
(error === :warn) && @warn s
end
return ie
end
function is_vector(
t::TraitList{<:IsGroupManifold},
G::GroupManifold,
e::Identity,
X,
cbp::Bool;
error::Symbol=:none,
kwargs...,
)
if cbp
ie = is_identity(G, e; kwargs...)
if !ie
s = "The provided identity is not a point on $G."
(error === :error) && throw(DomainError(e, s))
(error === :info) && @info s
(error === :warn) && @warn s
return false
end
end
return is_vector(G.manifold, identity_element(G), X, false; error=error, kwargs...)
end
Base.show(io::IO, G::GroupManifold) = print(io, "GroupManifold($(G.manifold), $(G.op))")