DistanceMatrices

org.appliedtopology.tda4j.DistanceMatrices

Shared triangular-distance-matrix arithmetic, used by both CSV and Ripser -- the two families of format that store a distance matrix as a flat list of triangular entries rather than a dense grid. Kept as one implementation rather than two so the "which row has how many entries, in what order" convention can't silently drift apart between the two call sites.

Attributes

Experimental
true
Source
DistanceMatrices.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def expandLowerTriangular(flat: IndexedSeq[Double], n: Int): Array[Array[Double]]

flat holds, for i = 1 until n, the i entries d(i,0),...,d(i,i-1), rows concatenated in order -- both Ripser's own LOWER_DISTANCE_MATRIX/DISTANCE_MATRIX text formats and CSV.readLowerTriangularDistanceMatrix use this exact convention. Expanded here into a full symmetric n x n matrix with zero diagonal.

flat holds, for i = 1 until n, the i entries d(i,0),...,d(i,i-1), rows concatenated in order -- both Ripser's own LOWER_DISTANCE_MATRIX/DISTANCE_MATRIX text formats and CSV.readLowerTriangularDistanceMatrix use this exact convention. Expanded here into a full symmetric n x n matrix with zero diagonal.

Attributes

Source
DistanceMatrices.scala
def expandUpperTriangular(flat: IndexedSeq[Double], n: Int): Array[Array[Double]]

The full matrix from its entries above the diagonal, row by row (d(0,1), ..., d(0,n-1), d(1,2), ...), Ripser's upper-distance convention.

The full matrix from its entries above the diagonal, row by row (d(0,1), ..., d(0,n-1), d(1,2), ...), Ripser's upper-distance convention.

Attributes

Source
DistanceMatrices.scala
def flattenLowerTriangular(m: Array[Array[Double]]): Array[Double]

Inverse of expandLowerTriangular: row i (1 until n) contributes d(i,0),...,d(i,i-1), in that order.

Inverse of expandLowerTriangular: row i (1 until n) contributes d(i,0),...,d(i,i-1), in that order.

Attributes

Source
DistanceMatrices.scala
def flattenUpperTriangular(m: Array[Array[Double]]): Array[Double]

Inverse of expandUpperTriangular.

Inverse of expandUpperTriangular.

Attributes

Source
DistanceMatrices.scala
def sizeFromTriangularCount(count: Int): Int

The n with n(n-1)/2 = count: the number of points of a triangular distance list without diagonal. Throws if there is none (a truncated file).

The n with n(n-1)/2 = count: the number of points of a triangular distance list without diagonal. Throws if there is none (a truncated file).

Attributes

Source
DistanceMatrices.scala