-
Notifications
You must be signed in to change notification settings - Fork 56
/
Lorentz.jl
64 lines (52 loc) · 1.92 KB
/
Lorentz.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
@doc raw"""
LorentzMetric <: AbstractMetric
Abstract type for Lorentz metrics, which have a single time dimension. These
metrics assume the spacelike convention with the time dimension being last,
giving the signature $(++...+-)$.
"""
abstract type LorentzMetric <: AbstractMetric end
@doc raw"""
MinkowskiMetric <: LorentzMetric
As a special metric of signature $(++...+-)$, i.e. a [`LorentzMetric`](@ref),
see [`minkowski_metric`](@ref) for the formula.
"""
struct MinkowskiMetric <: LorentzMetric end
@doc raw"""
Lorentz{T} = MetricManifold{Euclidean{T,ℝ},LorentzMetric}
The Lorentz manifold (or Lorentzian) is a pseudo-Riemannian manifold.
# Constructor
Lorentz(n[, metric=MinkowskiMetric()])
Generate the Lorentz manifold of dimension `n` with the [`LorentzMetric`](@ref) `m`,
which is by default set to the [`MinkowskiMetric`](@ref).
"""
const Lorentz = MetricManifold{ℝ,Euclidean{T,ℝ},<:LorentzMetric} where {T}
function Lorentz(n::Int, m::LorentzMetric=MinkowskiMetric(); parameter::Symbol=:type)
E = Euclidean(n; parameter=parameter)
return Lorentz(E, m)
end
function Lorentz(E::Euclidean{T}, m::LorentzMetric=MinkowskiMetric()) where {T}
return Lorentz{T,typeof(m)}(E, m)
end
function local_metric(M::Lorentz{<:Any,MinkowskiMetric}, p)
n = get_parameter(M.manifold.size)[1]
return Diagonal([ones(n - 1)..., -1])
end
function inner(::Lorentz{<:Any,MinkowskiMetric}, p, X, Y)
return minkowski_metric(X, Y)
end
@doc raw"""
minkowski_metric(a, b)
Compute the minkowski metric on $\mathbb R^n$ is given by
````math
⟨a,b⟩_{\mathrm{M}} = -a_{n}b_{n} +
\displaystyle\sum_{k=1}^{n-1} a_kb_k.
````
"""
function minkowski_metric(a, b)
a_part = @view a[1:(end - 1)]
b_part = @view b[1:(end - 1)]
return -a[end] * b[end] + dot(a_part, b_part)
end
function minkowski_metric(a::StaticVector{N}, b::StaticVector{N}) where {N}
return -a[N] * b[N] + dot(a[SOneTo(N - 1)], b[SOneTo(N - 1)])
end