CayleyMengerDeterminant.CayleyMengerDistanceMatrix
— TypeCayleyMengerDistanceMatrix{T,Sz}(simplex_dimensions::Int, square_distances::Vector{T}) where {T<:Real,Sz::Union{Int,Dynamic}}
CayleyMengerDistanceMatrix(points::Vararg{NTuple{N,T},N+1})::CayleyMengerDistanceMatrix{T,N} where {T<:Real,N::Int}
CayleyMengerDistanceMatrix(P::AbstractMatrix{T})::CayleyMengerDistanceMatrix{T,Dynamic} where {T<:Real}
The zero-diagonal symmetric matrix of square distances among the points of an N
-simplex, backed by efficient linear storage.
When providing points
, it must be N+1 tuples of N values each, which are the coordinates of the points of the N
-simplex. When providing P
, it must be a tall near-square matrix with N+1 rows and N columns, where the rows are the coordinates of the points of the N
-simplex. When providing simplex_dimensions
and square_distances
directly, simplex_dimensions
must be the integer number of dimension N
of the N-simplex, and
squaredistancesmust be the precomputed backing linear storage of the square distances among the points of the
N-simplex and so must have length
binomial2(simplexdimensions + 1)`.
CayleyMengerDeterminant.binomial2
— Functionbinomial2(x::Union{Int,StaticInt,Dynamic}) -> Union{Int,StaticInt,Dynamic}
Compute the second binomial coefficient of x
.
This function is a convenience shorthand for binomial(x, 2)
.
julia> binomial2(4)
6
CayleyMengerDeterminant.index_triangular_nodiag
— MethodCayleyMengerDeterminant.index_triangular_nodiag(ixA::Int, ixB::Int) -> Int
For row ixA
and column ixB
, compute the linear index into the flat vector storage for a symmetric or lower-triangular matrix with a zero diagonal.
ixA
and ixB
are both 1-based and contiguous, and ixA
is assumed to be greater than or equal to ixB
.
julia> CayleyMengerDeterminant.index_triangular_nodiag(4,2)
5
CayleyMengerDeterminant.inverse_binomial2
— Functioninverse_binomial2(x::Union{Int,StaticInt,Dynamic) -> Union{Int,StaticInt,Dynamic}
Compute the integer value that x
is the second binomial coefficient of.
This function is the inverse of binomial2
.
julia> inverse_binomial2(6)
4
CayleyMengerDeterminant.only_or_dynamic
— MethodComputes only
on all non-Dynamic()
arguments unless all arguments are Dynamic()
, in which case it returns Dynamic()
.
CayleyMengerDeterminant.simplex_volume
— Functionsimplex_volume(distances::CayleyMengerDistanceMatrix{T,Sz}; distance_type::Union{Nothing,Type{<:Real}} = nothing) where {N,T<:Real}
simplex_volume(points::Vararg{NTuple{N,T},N+1}; distance_type::Union{Nothing,Type{<:Real}} = nothing) where {N,T<:Real}
simplex_volume(P::AbstractMatrix{T}; distance_type::Union{Nothing,Type{<:Real}} = nothing) where {T<:Real}
Calculates the (interior) measure of an N
-simplex given the coordinates of its points, using the Cayley-Menger determinant involving the squared distances between the points.
For example, if N == 2
, then this function calculates the area of a triangle given the 2-dimensional coordinates of its 3 points; likewise, if N == 3
, then then this function calculates the volume of a tetrahedron given the 3-dimensional coordinates of its 4 points.
When providing points
, it must be N+1 tuples of N values each, which are the coordinates of the points of the N
-simplex. When providing P
, it must be a tall near-square matrix with N+1 rows and N columns, where the rows are the coordinates of the points of the N
-simplex.
If distance_type
is provided and is not nothing
, then the internal calculations on the squared distances will be done using distance_type
as the type; otherwise, the type used for the internal calculations will be automatically derived from T
.