Simplices
Ripserer.AbstractSimplex
— TypeAbstractSimplex{D, T}
An abstract type for representing simplices. A simplex must have a diameter of type T
, which is its birth time. The dimension must be encoded in the type as D
and can be accessed by dim
.
Interface
AbstractSimplex{D}(::NTuple{D+1, <:Integer}, ::T)
diam(::AbstractSimplex)
Base.sign(::AbstractSimplex)
Base.:-(::AbstractSimplex)
Base.isless(::AbstractSimplex, ::AbstractSimplex)
vertices(::AbstractSimplex)
coface_type(::AbstractSimplex)
coboundary(::Any, ::AbstractSimplex)
face_type(::AbstractSimplex)
only required for homology.boundary(::Any, ::AbstractSimplex)
only required for homology.
Ripserer.dim
— Methoddim(::AbstractSimplex)
dim(::Type{<:AbstractSimplex})
Get the dimension of simplex i.e. the value of D
.
dim(Simplex{2}((3, 2, 1), 3.2))
# output
2
Ripserer.diam
— Methoddiam(simplex::AbstractSimplex)
Get the diameter of simplex
.
diam(Simplex{2}((3, 2, 1), 3.2))
# output
3.2
Base.sign
— Methodsign(simplex::AbstractSimplex)
Get the orientation of simplex
. Returns -1 or 1.
sign(Simplex{2}((3, 2, 1), 3.2))
# output
+1
Base.:-
— Method-(simplex::AbstractSimplex)
Reverse the simplex orientation.
-Simplex{2}((3, 2, 1), 3.2)
# output
2-dim Simplex(1, 1):
-(3, 2, 1)
Ripserer.coface_type
— Methodcoface_type(::AbstractSimplex)
coface_type(::Type{<:AbstractSimplex})
Get the type of simplex's coface. For a D
-dimensional simplex, this is usually its D+1
-dimensional counterpart. Only the method for the type needs to be implemented.
coface_type(Simplex{2}((3, 2, 1), 3.2))
# output
Simplex{3, Float64, Int}
Ripserer.vertices
— Methodvertices(simplex::AbstractSimplex{dim})
Get the vertices of simplex
. Returns NTuple{dim+1, Int}
. In the algorithm, only the method for 2-simplices is actually used.
vertices(Simplex{2}((3, 2, 1), 3.2))
# output
(3, 2, 1)
Ripserer.coboundary
— Methodcoboundary(filtration, simplex[, Val{all_cofaces}])
Iterate over the coboundary of simplex
. Use the filtration
to determine the diameters and validity of cofaces. Iterates values of the type coface_type(simplex)
. If all_cofaces
is false
, only return cofaces with vertices added to the beginning of vertex list.
filtration = RipsFiltration([0 1 1 1; 1 0 1 1; 1 1 0 1; 1 1 1 0])
for c in coboundary(filtration, Simplex{1}(2, 1))
println(c)
end
# output
Simplex{2}(+(4, 3, 1), 1)
Simplex{2}(-(3, 2, 1), 1)
for c in coboundary(filtration, Simplex{1}(2, 1), Val(false))
println(c)
end
# output
Simplex{2}(+(4, 3, 1), 1)
Ripserer.IndexedSimplex
— TypeIndexedSimplex{D, T, I<:Integer} <: AbstractSimplex{D, T}
A refinement of AbstractSimplex
. An indexed simplex is represented by its dimension, diameter and combinatorial index. It does not need to hold information about its the vertices it includes, since they can be recomputed from the index and dimension.
By defining the index
, a default implementation of sign
, isless
, vertices
and coboundary
is provided.
Interface
IndexedSimplex{D[, T, I]}(index::I, diam::T)
- constructor.IndexedSimplex{D[, T, I]}(vertices::NTuple{D+1, I}, diam::T)
- constructor.diam(::AbstractSimplex)
coface_type(::AbstractSimplex)
index(::IndexedSimplex)
Ripserer.index
— Methodindex(vertices)
Calculate the index from tuple of vertices. The index is equal to
where $i_k$ are the simplex vertex indices.
Ripserer.Simplex
— TypeSimplex{D, T, I} <: IndexedSimplex{D, T, I}
The vanilla simplex type represented by dimension D
and index of type I
and a diameter of type T
.
Constructor
Simplex{D[, T, I]}(::I, ::T)
Examples
Simplex{2}(2, 1)
# output
2-dim Simplex{2}(2, 1):
+(4, 2, 1)
Simplex{10}(Int128(-10), 1.0)
# output
4-dim Simplex{3}(1.0, 10, 2) with UInt128 index:
-(12, 11, 10, 9, 8, 7, 6, 5, 4, 2, 1)
Ripserer.Cubelet
— TypeCubelet{D, T, I} <: IndexedSimplex{D, T, I}
A Cubelet
is similar to a Simplex
, but it has 2^D
vertices instead of D+1
. Like in Simplex
, the vertices are encoded from an index and dimension. Because a cubelet knows nothing about the image it came from, it returns linear indices from vertices
.
The vertices should be neighboring indices, but this fact is not checked anywhere.