-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathTorus.jl
46 lines (34 loc) · 1.58 KB
/
Torus.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
@doc raw"""
Torus{N} <: AbstractPowerManifold
The n-dimensional torus is the $n$-dimensional product of the [`Circle`](@ref).
The [`Circle`](@ref) is stored internally within `M.manifold`, such that all functions of
[`AbstractPowerManifold`](https://juliamanifolds.github.io/ManifoldsBase.jl/stable/manifolds.html#ManifoldsBase.AbstractPowerManifold) can be used directly.
"""
struct Torus{N} <: AbstractPowerManifold{ℝ,Circle{ℝ},ArrayPowerRepresentation}
manifold::Circle{ℝ}
end
Torus(n::Int) = Torus{n}(Circle())
Base.:^(M::Circle, n::Int) = Torus{n}(M)
@doc raw"""
check_point(M::Torus{n},p)
Checks whether `p` is a valid point on the [`Torus`](@ref) `M`, i.e. each of
its entries is a valid point on the [`Circle`](@ref) and the length of `x` is `n`.
"""
check_point(::Torus, ::Any)
function check_point(M::Torus{N}, p; kwargs...) where {N}
return check_point(PowerManifold(M.manifold, N), p; kwargs...)
end
@doc raw"""
check_vector(M::Torus{n}, p, X; kwargs...)
Checks whether `X` is a valid tangent vector to `p` on the [`Torus`](@ref) `M`.
This means, that `p` is valid, that `X` is of correct dimension and elementwise
a tangent vector to the elements of `p` on the [`Circle`](@ref).
"""
function check_vector(M::Torus{N}, p, X; kwargs...) where {N}
return check_vector(PowerManifold(M.manifold, N), p, X; kwargs...)
end
get_iterator(::Torus{N}) where {N} = 1:N
manifold_dimension(::Torus{N}) where {N} = N
power_dimensions(::Torus{N}) where {N} = (N,)
representation_size(::Torus{N}) where {N} = (N,)
Base.show(io::IO, ::Torus{N}) where {N} = print(io, "Torus($(N))")