ParallelPackedCohomology

org.appliedtopology.tda4j.ParallelPackedCohomology

The engine behind Persistence.Engine.ParallelRipser (#192, #194, #220): Vietoris-Rips persistent cohomology over F_p on implicit coboundaries, as the packed Ripser engine computes it (clearing, apparent pairs, a heap working column, cofacets enumerated on the fly), with each degree's columns cut into units of whole edge blocks and the units reduced in parallel. A column whose pivot leaves its unit is deferred: the deferred columns go on in parallel while their pivots are owned by the units' pairs (phase 2a), then one by one in the sequential order (phase 2b). The pairs, and the reduction log of every column, are those of one sequential reduction in the same order.

A simplex is one Long key: its block (1 + the rank of its last longest edge, edges ranked by length and then by an EdgeTies order, the lexicographic one unless asked otherwise; 0 for a vertex) above its combinatorial index index, or mask - index when a larger index is older (the default, as in the packed engine; BlockOrder chooses). Within one dimension, ascending keys are the filtration order, oldest first. When the block and the index do not fit in one Long together (Space.wide), a key is the index part alone, which still names the simplex within its dimension, and the block beside it in every array, heap and column that orders keys; the order is then by block, then key. Coefficients are Ints mod p.

persistence(space, threads, unitsPerThread, ...) cuts each degree into threads * unitsPerThread units; they run on the threads Parallel has where the call is (Parallel.withThreads(n), else the common pool), one after the other when threads is 1 and on JavaScript. threads 1 with 1 unit per thread is the sequential reduction. The command-line driver is ParallelPackedCohomologyDriver (JVM, in the test tree).

Attributes

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

Members list

Type members

Classlikes

enum BlockOrder

Which of two simplices of one dimension filed under the same block (the same last longest edge) enters the filtration first, by combinatorial index: the index of {v_0 < ... < v_k} is C(v_k, k + 1) + ... + C(v_0, 1), the order of the combinatorial number system. Every direction gives the same barcode; they differ in which pairs are apparent, since the oldest cofacet of a column and the youngest facet of a cofacet are the ones that add and drop the largest vertex outside the block's edge in one direction, and the smallest in the other.

Which of two simplices of one dimension filed under the same block (the same last longest edge) enters the filtration first, by combinatorial index: the index of {v_0 < ... < v_k} is C(v_k, k + 1) + ... + C(v_0, 1), the order of the combinatorial number system. Every direction gives the same barcode; they differ in which pairs are apparent, since the oldest cofacet of a column and the youngest facet of a cofacet are the ones that add and drop the largest vertex outside the block's edge in one direction, and the smallest in the other.

  • LargerIndexFirst (default): the larger index is older: Ripser's own order within a diameter. The oldest cofacet of a column adds the largest qualifying vertex.
  • SmallerIndexFirst: the smaller index is older: the order of Bauer's hybrid and ripser-forest (ORDER_CONVENTIONS.md of ripser-dev). The oldest cofacet adds the smallest qualifying vertex.

Vertices (which share block 0) and the simplices of dimension 1 (one to a block) follow it too, which changes which vertex of a merging pair is the older and so only the pairing of degree 0, never its bars.

Attributes

Companion
object
Source
ParallelPackedCohomology.scala
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object BlockOrder

Attributes

Companion
enum
Source
ParallelPackedCohomology.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
BlockOrder.type
open class Deferred(val column: Long, val columnBlock: Int, var keys: Array[Long], var coefs: Array[Int], var blocks: Array[Int], val log: Log)

A column whose pivot left its unit: its working column (blocks as in Owner) and its reduction log so far.

A column whose pivot left its unit: its working column (blocks as in Owner) and its reduction log so far.

Attributes

Source
ParallelPackedCohomology.scala
Supertypes
class Object
trait Matchable
class Any
open class Degree(val degree: Int, val stats: Stats)

One degree's pairs (birth key, death key or -1), its owners with reduced columns, its logs.

One degree's pairs (birth key, death key or -1), its owners with reduced columns, its logs.

Attributes

Source
ParallelPackedCohomology.scala
Supertypes
class Object
trait Matchable
class Any
open class EdgeRankedMetricSpace(base: FiniteMetricSpace[Int], threshold: Double, ties: EdgeTies) extends FiniteMetricSpace[Int]

base with the length of every edge within threshold replaced by its rank, 1, 2, ... in the order of an EdgeRanking (0 on the diagonal, infinity past the threshold). An engine that orders simplices by diameter and then by index, run on this, orders them by their last edge in that ranking: ripser.cpp's edge-lexicographic order for EdgeTies.ReverseColexicographic (EDGE_LEXICOGRAPHIC), and the order of the other EdgeTies as they are named. Give the engine limit as its maxFiltrationValue, and read what comes back in lengths with lengthOf. Memory: the ranking, a dense table of n^2 Ints up to DenseRankLimit points, sorted neighbour lists above.

base with the length of every edge within threshold replaced by its rank, 1, 2, ... in the order of an EdgeRanking (0 on the diagonal, infinity past the threshold). An engine that orders simplices by diameter and then by index, run on this, orders them by their last edge in that ranking: ripser.cpp's edge-lexicographic order for EdgeTies.ReverseColexicographic (EDGE_LEXICOGRAPHIC), and the order of the other EdgeTies as they are named. Give the engine limit as its maxFiltrationValue, and read what comes back in lengths with lengthOf. Memory: the ranking, a dense table of n^2 Ints up to DenseRankLimit points, sorted neighbour lists above.

Attributes

Source
ParallelPackedCohomology.scala
Supertypes
trait FiniteMetricSpace[Int]
class Object
trait Matchable
class Any
open class EdgeRanking(val n: Int, distance: (Int, Int) => Double, val threshold: Double, val edgeTies: EdgeTies = ..., forceSparseRanks: Boolean = ..., edgeLists: => Option[NeighbourLists] = ...)

The edges of a metric within a threshold, ranked by length and then by an EdgeTies order, with each edge's rank looked up in a dense n x n table (up to DenseRankLimit points) or in sorted neighbour lists. A rank is a position in the filtration order of the edges: it is what Space files a simplex under, and what EdgeRankedMetricSpace hands an engine in place of the length.

The edges of a metric within a threshold, ranked by length and then by an EdgeTies order, with each edge's rank looked up in a dense n x n table (up to DenseRankLimit points) or in sorted neighbour lists. A rank is a position in the filtration order of the edges: it is what Space files a simplex under, and what EdgeRankedMetricSpace hands an engine in place of the length.

Attributes

Source
ParallelPackedCohomology.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Space
enum EdgeTies

How edges of one length are ranked, which decides the edge a simplex is filed under: its block is that of the last, in this order, of its longest edges. Every order gives the same barcode; they differ in which zero-length pairs form and so in how many columns need reducing. An edge is {a, b} with a < b; its combinatorial index is C(b, 2) + a.

How edges of one length are ranked, which decides the edge a simplex is filed under: its block is that of the last, in this order, of its longest edges. Every order gives the same barcode; they differ in which zero-length pairs form and so in how many columns need reducing. An edge is {a, b} with a < b; its combinatorial index is C(b, 2) + a.

  • Lexicographic (default): by a, then by b, ascending. The simplex's block is the lexicographically largest of its longest edges. This is Bauer's --ties lexicographic (ripser-dev, hybrid/pruned.cpp).
  • ReverseLexicographic: by a, then by b, descending.
  • Colexicographic: by b, then by a, ascending: increasing combinatorial index. The block is that of the largest-index longest edge: the order of Bauer's hybrid and ripser-forest (--ties increasing, their default).
  • ReverseColexicographic: decreasing combinatorial index. The block is that of the smallest-index longest edge: Ripser's own order of equal edges, as in ripser.cpp built with EDGE_LEXICOGRAPHIC (--ties decreasing).
  • Shuffled: by a fixed hash of the combinatorial index (Bauer's --ties random): a control that has no structure to exploit.

Attributes

Companion
object
Source
ParallelPackedCohomology.scala
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object EdgeTies

Attributes

Companion
enum
Source
ParallelPackedCohomology.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
EdgeTies.type
open class Heap(wide: Boolean, bits: Int)

A working column: a binary min-heap of (key, coefficient), equal keys combined when they reach the top. With two-word keys (wide) each entry also holds its block, and entries are ordered by block, then key.

A working column: a binary min-heap of (key, coefficient), equal keys combined when they reach the top. With two-word keys (wide) each entry also holds its block, and entries are ordered by block, then key.

Attributes

Source
ParallelPackedCohomology.scala
Supertypes
class Object
trait Matchable
class Any
open class Log

The columns added to one column, with their factors: V = column + sum of factor * V(added).

The columns added to one column, with their factors: V = column + sum of factor * V(added).

Attributes

Source
ParallelPackedCohomology.scala
Supertypes
class Object
trait Matchable
class Any
open class Owner(val column: Long, val columnBlock: Int, val keys: Array[Long], val coefs: Array[Int], val blocks: Array[Int] = ..., val pivotBlock: Int = ...)

The column that owns a pivot, with its block: its reduced coboundary, or null arrays when that is its own coboundary (blocks: the reduced column's blocks, for two-word keys only); pivotBlock the pivot's block, or -1 for an owner that is only looked up.

The column that owns a pivot, with its block: its reduced coboundary, or null arrays when that is its own coboundary (blocks: the reduced column's blocks, for two-word keys only); pivotBlock the pivot's block, or -1 for an owner that is only looked up.

Attributes

Source
ParallelPackedCohomology.scala
Supertypes
class Object
trait Matchable
class Any
open class Result(val space: Space, val degrees: Vector[Degree])

Attributes

Source
ParallelPackedCohomology.scala
Supertypes
class Object
trait Matchable
class Any
open class Space(nPoints: Int, distance: (Int, Int) => Double, threshold0: Double, val maxDim: Int, val p: Int, val ripserApparent: Boolean = ..., forceWide: Boolean = ..., forceSparseRanks: Boolean = ..., edgeTies: EdgeTies = ..., val blockOrder: BlockOrder = ..., edgeLists: => Option[NeighbourLists] = ...) extends EdgeRanking

The edges within the threshold ranked, and the key encoding.

The edges within the threshold ranked, and the key encoding.

Attributes

Source
ParallelPackedCohomology.scala
Supertypes
class EdgeRanking
class Object
trait Matchable
class Any
open class Stats(val degree: Int, val columns: Int, val cleared: Int)

Per-degree counts and times.

Per-degree counts and times.

Attributes

Source
ParallelPackedCohomology.scala
Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

def blockOf(space: Space, vs: Array[Int], k: Int): Int

Attributes

Source
ParallelPackedCohomology.scala
def coboundaryOf(space: Space, k: Int, cochain: Map[Long, Int]): Map[Long, Int]

The coboundary of a cochain of keys of size k, as a map key -> coefficient (zeros dropped).

The coboundary of a cochain of keys of size k, as a map key -> coefficient (zeros dropped).

Attributes

Source
ParallelPackedCohomology.scala
def cocycle(degree: Degree, p: Int, column: Long): Map[Long, Int]

V for a column: the column plus factor * V(added) over its log, expanded depth-first without recursion.

V for a column: the column plus factor * V(added) over its log, expanded depth-first without recursion.

Attributes

Source
ParallelPackedCohomology.scala
def persistence(space: Space, threads: Int, unitsPerThread: Int, cocycles: Boolean, keepPairs: Boolean = ...): Result

Every bar of degrees 0 .. maxDim; unitsPerThread 1 with threads 1 is the sequential reduction.

Every bar of degrees 0 .. maxDim; unitsPerThread 1 with threads 1 is the sequential reduction.

Attributes

Source
ParallelPackedCohomology.scala

Concrete fields

val DenseRankLimit: Int

Up to this many points the rank of an edge is looked up in a dense n x n table (at most 64 MB); above it, in the sorted neighbour list of one end (memory proportional to the edges, and no n x n array). The table is about a quarter faster where nearly every pair is an edge; the lists need a fifth of the memory on sparse graphs.

Up to this many points the rank of an edge is looked up in a dense n x n table (at most 64 MB); above it, in the sorted neighbour list of one end (memory proportional to the edges, and no n x n array). The table is about a quarter faster where nearly every pair is an edge; the lists need a fifth of the memory on sparse graphs.

Attributes

Source
ParallelPackedCohomology.scala
val MaxEdges: Int

The most edges a Space takes: they are indexed by Int ranks in arrays.

The most edges a Space takes: they are indexed by Int ranks in arrays.

Attributes

Source
ParallelPackedCohomology.scala
val MaxPrime: Int

The largest prime a run can use: coefficients are Ints, and (p - 1)^2 + p must not overflow.

The largest prime a run can use: coefficients are Ints, and (p - 1)^2 + p must not overflow.

Attributes

Source
ParallelPackedCohomology.scala