-
Notifications
You must be signed in to change notification settings - Fork 56
/
VectorBundle.jl
418 lines (354 loc) · 14 KB
/
VectorBundle.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
"""
const VectorBundleVectorTransport = FiberBundleProductVectorTransport
Deprecated: an alias for `FiberBundleProductVectorTransport`.
"""
const VectorBundleVectorTransport = FiberBundleProductVectorTransport
"""
fiber_bundle_transport(M::AbstractManifold, fiber::FiberType)
Determine the vector transport used for [`exp`](@ref exp(::FiberBundle, ::Any...)) and
[`log`](@ref log(::FiberBundle, ::Any...)) maps on a vector bundle with fiber type
`fiber` and manifold `M`.
"""
fiber_bundle_transport(M::AbstractManifold, ::FiberType) =
default_vector_transport_method(M)
"""
VectorBundle{𝔽,TVS,TM,VTV} = FiberBundle{𝔽,TVS,TM,TVT} where {TVS<:VectorSpaceType}
Alias for [`FiberBundle`](@ref) when fiber type is a `TVS` of type
[`VectorSpaceType`]https://juliamanifolds.github.io/ManifoldsBase.jl/stable/bases/#ManifoldsBase.VectorSpaceType).
`VectorSpaceFiberType` is used to encode vector spaces as fiber types.
"""
const VectorBundle{𝔽,TVS,TM,TVT} = FiberBundle{
𝔽,
TVS,
TM,
TVT,
} where {
TVS<:VectorSpaceType,
TM<:AbstractManifold{𝔽},
TVT<:FiberBundleProductVectorTransport,
}
"""
TangentBundle{𝔽,M} = VectorBundle{𝔽,TangentSpaceType,M} where {𝔽,M<:AbstractManifold{𝔽}}
Tangent bundle for manifold of type `M`, as a manifold with the Sasaki metric [Sasaki:1958](@cite).
Exact retraction and inverse retraction can be approximated using [`FiberBundleProductRetraction`](@ref),
[`FiberBundleInverseProductRetraction`](@ref) and [`SasakiRetraction`](https://juliamanifolds.github.io/ManifoldsBase.jl/stable/retractions/#ManifoldsBase.SasakiRetraction).
[`FiberBundleProductVectorTransport`](@ref) can be used as a vector transport.
# Constructors
TangentBundle(M::AbstractManifold)
TangentBundle(M::AbstractManifold, vtm::FiberBundleProductVectorTransport)
"""
const TangentBundle{𝔽,M} =
VectorBundle{𝔽,TangentSpaceType,M} where {𝔽,M<:AbstractManifold{𝔽}}
TangentBundle(M::AbstractManifold) = FiberBundle(TangentSpaceType(), M)
function TangentBundle(M::AbstractManifold, vtm::FiberBundleProductVectorTransport)
return FiberBundle(TangentSpaceType(), M, vtm)
end
const CotangentBundle{𝔽,M} =
VectorBundle{𝔽,CotangentSpaceType,M} where {𝔽,M<:AbstractManifold{𝔽}}
CotangentBundle(M::AbstractManifold) = FiberBundle(CotangentSpaceType(), M)
function CotangentBundle(M::AbstractManifold, vtm::FiberBundleProductVectorTransport)
return FiberBundle(CotangentSpaceType(), M, vtm)
end
function bundle_transport_to!(B::TangentBundle, Y, p, X, q)
return vector_transport_to!(B.manifold, Y, p, X, q, B.vector_transport.method_vertical)
end
function bundle_transport_tangent_direction!(
B::TangentBundle,
Y,
p,
pf,
X,
d,
m::AbstractVectorTransportMethod=default_vector_transport_method(B.manifold),
)
return vector_transport_direction!(B.manifold, Y, p, X, d, m)
end
function bundle_transport_tangent_to!(
B::TangentBundle,
Y,
p,
pf,
X,
q,
m::AbstractVectorTransportMethod=default_vector_transport_method(B.manifold),
)
return vector_transport_to!(B.manifold, Y, p, X, q, m)
end
function default_inverse_retraction_method(::TangentBundle)
return FiberBundleInverseProductRetraction()
end
function default_retraction_method(::TangentBundle)
return FiberBundleProductRetraction()
end
function default_vector_transport_method(B::TangentBundle)
default_vt_m = default_vector_transport_method(B.manifold)
return FiberBundleProductVectorTransport(default_vt_m, default_vt_m)
end
"""
injectivity_radius(M::TangentBundle)
Injectivity radius of [`TangentBundle`](@ref) manifold is infinite if the base manifold
is flat and 0 otherwise.
See [https://mathoverflow.net/questions/94322/injectivity-radius-of-the-sasaki-metric](https://mathoverflow.net/questions/94322/injectivity-radius-of-the-sasaki-metric).
"""
function injectivity_radius(M::TangentBundle)
if is_flat(M.manifold)
return Inf
else
return 0.0
end
end
@doc raw"""
inner(B::VectorBundle, p, X, Y)
Inner product of tangent vectors `X` and `Y` at point `p` from the
vector bundle `B` over manifold `B.fiber` (denoted ``\mathcal M``).
Notation:
* The point ``p = (x_p, V_p)`` where ``x_p ∈ \mathcal M`` and ``V_p`` belongs to the
fiber ``F=π^{-1}(\{x_p\})`` of the vector bundle ``B`` where ``π`` is the
canonical projection of that vector bundle ``B``.
* The tangent vector ``v = (V_{X,M}, V_{X,F}) ∈ T_{x}B`` where
``V_{X,M}`` is a tangent vector from the tangent space ``T_{x_p}\mathcal M`` and
``V_{X,F}`` is a tangent vector from the tangent space ``T_{V_p}F`` (isomorphic to ``F``).
Similarly for the other tangent vector ``w = (V_{Y,M}, V_{Y,F}) ∈ T_{x}B``.
The inner product is calculated as
``⟨X, Y⟩_p = ⟨V_{X,M}, V_{Y,M}⟩_{x_p} + ⟨V_{X,F}, V_{Y,F}⟩_{V_p}.``
"""
function inner(B::FiberBundle, p, X, Y)
px, Vx = submanifold_components(B.manifold, p)
VXM, VXF = submanifold_components(B.manifold, X)
VYM, VYF = submanifold_components(B.manifold, Y)
F = Fiber(B.manifold, px, B.type)
# for tangent bundle Vx is discarded by the method of inner for TangentSpace
# and px is actually used as the base point
return inner(B.manifold, px, VXM, VYM) + inner(F, Vx, VXF, VYF)
end
function _inverse_retract(M::FiberBundle, p, q, ::FiberBundleInverseProductRetraction)
return inverse_retract_product(M, p, q)
end
function _inverse_retract!(M::FiberBundle, X, p, q, ::FiberBundleInverseProductRetraction)
return inverse_retract_product!(M, X, p, q)
end
"""
inverse_retract(M::VectorBundle, p, q, ::FiberBundleInverseProductRetraction)
Compute the allocating variant of the [`FiberBundleInverseProductRetraction`](@ref),
which by default allocates and calls `inverse_retract_product!`.
"""
inverse_retract(::VectorBundle, p, q, ::FiberBundleInverseProductRetraction)
function inverse_retract_product(M::VectorBundle, p, q)
X = allocate_result(M, inverse_retract, p, q)
return inverse_retract_product!(M, X, p, q)
end
function inverse_retract_product!(B::VectorBundle, X, p, q)
px, Vx = submanifold_components(B.manifold, p)
py, Vy = submanifold_components(B.manifold, q)
VXM, VXF = submanifold_components(B.manifold, X)
log!(B.manifold, VXM, px, py)
bundle_transport_to!(B, VXF, py, Vy, px)
copyto!(VXF, VXF - Vx)
return X
end
"""
is_flat(::VectorBundle)
Return true if the underlying manifold of [`VectorBundle`](@ref) `M` is flat.
"""
is_flat(M::VectorBundle) = is_flat(M.manifold)
@doc raw"""
project(B::VectorBundle, p)
Project the point `p` from the ambient space of the vector bundle `B`
over manifold `B.fiber` (denoted ``\mathcal M``) to the vector bundle.
Notation:
* The point ``p = (x_p, V_p)`` where ``x_p`` belongs to the ambient space of ``\mathcal M``
and ``V_p`` belongs to the ambient space of the
fiber ``F=π^{-1}(\{x_p\})`` of the vector bundle ``B`` where ``π`` is the
canonical projection of that vector bundle ``B``.
The projection is calculated by projecting the point ``x_p`` to the manifold ``\mathcal M``
and then projecting the vector ``V_p`` to the tangent space ``T_{x_p}\mathcal M``.
"""
project(::VectorBundle, ::Any)
function project!(B::VectorBundle, q, p)
px, pVx = submanifold_components(B.manifold, p)
qx, qVx = submanifold_components(B.manifold, q)
project!(B.manifold, qx, px)
F = Fiber(B.manifold, qx, B.type)
project!(F, qVx, pVx)
return q
end
@doc raw"""
project(B::VectorBundle, p, X)
Project the element `X` of the ambient space of the tangent space ``T_p B``
to the tangent space ``T_p B``.
Notation:
* The point ``p = (x_p, V_p)`` where ``x_p ∈ \mathcal M`` and ``V_p`` belongs to the
fiber ``F=π^{-1}(\{x_p\})`` of the vector bundle ``B`` where ``π`` is the
canonical projection of that vector bundle ``B``.
* The vector ``x = (V_{X,M}, V_{X,F})`` where ``x_p`` belongs to the ambient space of
``T_{x_p}\mathcal M`` and ``V_{X,F}`` belongs to the ambient space of the
fiber ``F=π^{-1}(\{x_p\})`` of the vector bundle ``B`` where ``π`` is the
canonical projection of that vector bundle ``B``.
The projection is calculated by projecting ``V_{X,M}`` to tangent space ``T_{x_p}\mathcal M``
and then projecting the vector ``V_{X,F}`` to the fiber ``F``.
"""
project(::VectorBundle, ::Any, ::Any)
function project!(B::VectorBundle, Y, p, X)
px, Vx = submanifold_components(B.manifold, p)
VXM, VXF = submanifold_components(B.manifold, X)
VYM, VYF = submanifold_components(B.manifold, Y)
F = Fiber(B.manifold, px, B.type)
project!(B.manifold, VYM, px, VXM)
project!(F, VYF, Vx, VXF)
return Y
end
function _retract!(M::VectorBundle, q, p, X, t::Number, ::FiberBundleProductRetraction)
return retract_product!(M, q, p, X, t)
end
"""
retract(M::VectorBundle, p, q, t::Number, ::FiberBundleProductRetraction)
Compute the allocating variant of the [`FiberBundleProductRetraction`](@ref),
which by default allocates and calls `retract_product!`.
"""
retract(::VectorBundle, p, q, t::Number, ::FiberBundleProductRetraction)
function _retract(M::VectorBundle, p, X, t::Number, ::FiberBundleProductRetraction)
return retract_product(M, p, X, t)
end
function retract_product(M::VectorBundle, p, X, t::Number)
q = allocate_result(M, retract, p, X)
return retract_product!(M, q, p, X, t)
end
function retract_product!(B::VectorBundle, q, p, X, t::Number)
tX = t * X
xp, Xp = submanifold_components(B.manifold, p)
xq, Xq = submanifold_components(B.manifold, q)
VXM, VXF = submanifold_components(B.manifold, tX)
# this temporary avoids overwriting `p` when `q` and `p` occupy the same memory
xqt = exp(B.manifold, xp, VXM)
vector_transport_direction!(
B.manifold,
Xq,
xp,
Xp + VXF,
VXM,
B.vector_transport.method_horizontal,
)
copyto!(B.manifold, xq, xqt)
return q
end
function retract_sasaki!(B::TangentBundle, q, p, X, t::Number, m::SasakiRetraction)
tX = t * X
xp, Xp = submanifold_components(B.manifold, p)
xq, Xq = submanifold_components(B.manifold, q)
VXM, VXF = submanifold_components(B.manifold, tX)
p_k = allocate(B.manifold, xp)
copyto!(B.manifold, p_k, xp)
X_k = allocate(B.manifold, Xp)
copyto!(B.manifold, X_k, Xp)
Y_k = allocate(B.manifold, VXM)
copyto!(B.manifold, Y_k, VXM)
Z_k = allocate(B.manifold, VXF)
copyto!(B.manifold, Z_k, VXF)
ϵ = 1 / m.L
for k in 1:(m.L)
p_kp1 = exp(B.manifold, p_k, ϵ * Y_k)
X_kp1 = parallel_transport_to(B.manifold, p_k, X_k .+ ϵ .* Z_k, p_kp1)
Y_kp1 = parallel_transport_to(
B.manifold,
p_k,
Y_k .+ ϵ .* riemann_tensor(B.manifold, p_k, X_k, Z_k, Y_k),
p_kp1,
)
Z_kp1 = parallel_transport_to(B.manifold, p_k, Z_k, p_kp1)
copyto!(B.manifold, p_k, p_kp1)
copyto!(B.manifold, X_k, p_kp1, X_kp1)
copyto!(B.manifold, Y_k, p_kp1, Y_kp1)
copyto!(B.manifold, Z_k, p_kp1, Z_kp1)
end
copyto!(B.manifold, xq, p_k)
copyto!(B.manifold, Xq, xq, X_k)
return q
end
Base.show(io::IO, vb::TangentBundle) = print(io, "TangentBundle($(vb.manifold))")
function vector_transport_direction(M::VectorBundle, p, X, d)
return vector_transport_direction(M, p, X, d, M.vector_transport)
end
function vector_transport_direction!(M::VectorBundle, Y, p, X, d)
return vector_transport_direction!(M, Y, p, X, d, M.vector_transport)
end
function _vector_transport_direction!(
M::VectorBundle,
Y,
p,
X,
d,
m::FiberBundleProductVectorTransport,
)
VYM, VYF = submanifold_components(M.manifold, Y)
px, pVx = submanifold_components(M.manifold, p)
VXM, VXF = submanifold_components(M.manifold, X)
dx, dVx = submanifold_components(M.manifold, d)
vector_transport_direction!(M.manifold, VYM, px, VXM, dx, m.method_horizontal),
vector_transport_direction!(M.manifold, VYF, px, VXF, dx, m.method_vertical),
return Y
end
@doc raw"""
vector_transport_to(M::VectorBundle, p, X, q, m::FiberBundleProductVectorTransport)
Compute the vector transport the tangent vector `X`at `p` to `q` on the
[`VectorBundle`](@ref) `M` using the [`FiberBundleProductVectorTransport`](@ref) `m`.
"""
vector_transport_to(
::VectorBundle,
::Any,
::Any,
::Any,
::FiberBundleProductVectorTransport,
)
function vector_transport_to(M::VectorBundle, p, X, q)
return vector_transport_to(M, p, X, q, M.vector_transport)
end
function vector_transport_to!(M::VectorBundle, Y, p, X, q)
return vector_transport_to!(M, Y, p, X, q, M.vector_transport)
end
function vector_transport_to!(
M::TangentBundle,
Y,
p,
X,
q,
m::FiberBundleProductVectorTransport,
)
px, pVx = submanifold_components(M.manifold, p)
VXM, VXF = submanifold_components(M.manifold, X)
VYM, VYF = submanifold_components(M.manifold, Y)
qx, qVx = submanifold_components(M.manifold, q)
vector_transport_to!(M.manifold, VYM, px, VXM, qx, m.method_horizontal)
bundle_transport_tangent_to!(M, VYF, px, pVx, VXF, qx, m.method_vertical)
return Y
end
function _vector_transport_direction(
M::VectorBundle,
p,
X,
d,
m::FiberBundleProductVectorTransport,
)
px, pVx = submanifold_components(M.manifold, p)
VXM, VXF = submanifold_components(M.manifold, X)
dx, dVx = submanifold_components(M.manifold, d)
return ArrayPartition(
vector_transport_direction(M.manifold, px, VXM, dx, m.method_horizontal),
bundle_transport_tangent_direction(M, px, pVx, VXF, dx, m.method_vertical),
)
end
function _vector_transport_to(
M::VectorBundle,
p,
X,
q,
m::FiberBundleProductVectorTransport,
)
px, pVx = submanifold_components(M.manifold, p)
VXM, VXF = submanifold_components(M.manifold, X)
qx, qVx = submanifold_components(M.manifold, q)
return ArrayPartition(
vector_transport_to(M.manifold, px, VXM, qx, m.method_horizontal),
bundle_transport_tangent_to(M, px, pVx, VXF, qx, m.method_vertical),
)
end
Base.show(io::IO, vb::CotangentBundle) = print(io, "CotangentBundle($(vb.manifold))")