-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.jl
27 lines (20 loc) · 854 Bytes
/
utils.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
export dimension
"""
dimension( vertices :: Vector{Vector{Int64}} ) :: Int64
For the provided vertices (points), finds the dimension of the affine space spanned
by the vertices. This method computes the dimension of a polytope, facet, or
collection of points.
This also accepts matrices and `DeterministicStrategy` types as arguments:
dimension( vertices :: Vector{Matrix{Int64}} ) :: Int64
dimension( vertices :: Vector{DeterministicStrategy} ) :: Int64
"""
function dimension(vertices :: Vector{Vector{Int64}}) :: Int64
vectors = map( v -> v - vertices[1], vertices[2:end])
rank(hcat(vectors...))
end
function dimension(vertices :: Vector{Matrix{Int64}}) :: Int64
dimension(map( v -> v[:], vertices))
end
function dimension(vertices :: Vector{DeterministicStrategy}) :: Int64
dimension(map(v -> v[:], vertices))
end