HarmonicChainBarcode

org.appliedtopology.tda4j.HarmonicChainBarcode

The harmonic chain barcode of a filtered complex (Hou, Parsa and Wang, "Tracking the persistence of harmonic chains", SoCG 2025): the barcode that follows the harmonic chains H_p(K_t) = ker ∂_p ∩ ker ∂_{p+1}^T (cycles orthogonal to all boundaries, the kernel of the Hodge Laplacian) along the filtration. Each bar is a harmonic cycle that stays harmonic for the bar's whole life, so it needs no choice of representative, and the representative the bar carries is that one cycle.

val rips = VietorisRips(points, maxDimension = 1)
val diagram = HarmonicChainBarcode(rips, maxDimension = 1)
diagram.bars.head.representative   // a chain that is a cycle and a cocycle at every value of its bar

It is NOT the ordinary barcode. When a cell enters, the harmonic chains of the complex change by a whole class at a time, and a cycle stops being harmonic as soon as it is no longer orthogonal to the boundaries, which happens before it becomes a boundary: a filtration in which the ordinary barcode has the bars [4, 9), [5, 10), [7, 8) can have the harmonic bars [4, 8), [5, 9), [7, 10) (the example of the paper, a spec of this library). The number of bars alive at each value is the Betti number there, as for the ordinary barcode. A bar [b, d) is born when the cell that creates its cycle enters (at b) and ends when the cell enters that makes the cycle non-orthogonal to a boundary (at d); the two cells are the bar's PersistenceBar.birthCell and PersistenceBar.deathCell.

The barcode is defined for a simplex-wise filtration, one cell entering at a time, and the harmonic chains of the complexes in between depend on the order in which cells of equal filtration value enter. HarmonicChainBarcode(stream) takes them in the order value, then dimension (so a face comes before its cofaces), then the stream's own order within a dimension (insertionOrder), as the paper fixes an order too; ofOrder takes any order. A bar born and gone at one value is left out unless includeZeroLength = true.

The representative of a bar (Algorithm 1 of the paper): when a cell creates a cycle, the harmonic chain that is new is the one orthogonal to every earlier cycle (the Gram-Schmidt step; the paper's coboundary basis finds the same chain), and when a cell closes a class, the oldest harmonic chain that is no longer orthogonal to its boundary ends the bar, and the other chains that are not orthogonal have a multiple of it subtracted. It is the bar's chain at the moment the bar ends, and it was harmonic from the moment the bar began.

In a Vietoris-Rips filtration a triangle enters at the value of its longest edge: if that edge starts a new loop, the triangle ends the oldest loop it is not orthogonal to, so a long ordinary bar is cut there and appears as consecutive bars. For the ordinary bars with harmonic representatives use HarmonicRepresentatives. The births and deaths are always those of the ordinary barcode, paired differently.

Harmonic means an inner product, so the coefficients are the real numbers (Coefficients(0), the default; a tolerance decides which entries are zero) or the exact rationals (Coefficients.Rationals, no tolerance: the numbers can grow), and a finite field is refused: the dot product is not positive definite there, so a chain can be orthogonal to itself and the algorithm divides by its length. The result is an ordinary PersistenceDiagram whose bars carry their cells, so every tool for diagrams applies; its representatives are chains that are both cycles and cocycles. The cost is O(m^3) for m cells in the worst case (the paper's bound) and the chains are kept sparse.

Attributes

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

Members list

Type members

Classlikes

How the chain a positive cell creates is made orthogonal to every older cycle (the step of Algorithm 1 that costs memory). Both give the same chain: the one cycle with coefficient 1 on the cell that is orthogonal to the cycles of the complex before it. Over the rationals the two agree term for term. Over the reals every decision of the algorithm is a test against the field's tolerance, so on a large complex with many near ties a cycle that is almost orthogonal to a boundary can be judged differently by the two, and a few bars are then paired differently; Coefficients.Rationals gives the exact pairing.

How the chain a positive cell creates is made orthogonal to every older cycle (the step of Algorithm 1 that costs memory). Both give the same chain: the one cycle with coefficient 1 on the cell that is orthogonal to the cycles of the complex before it. Over the rationals the two agree term for term. Over the reals every decision of the algorithm is a test against the field's tolerance, so on a large complex with many near ties a cycle that is almost orthogonal to a boundary can be judged differently by the two, and a few bars are then paired differently; Coefficients.Rationals gives the exact pairing.

  • GramSchmidt: the orthogonal basis of all the cycles of the degree is kept, and the new chain is orthogonalised against it. The basis grows with every positive cell and holds a dense chain for each.
  • LaplacianSolve: nothing is kept but the boundaries and an index of the cofaces. With z = e_σ + ∂ᵀ y, y solves (∂ ∂ᵀ) y = -∂σ on the cells of the degree below, the boundary ∂ being that of the cells of σ's dimension that entered before it (conjugate gradient, which finishes exactly over the rationals). The memory is a fraction of the basis; over the reals the solve stops when its residual is zero to the field's tolerance, and gives up with an error that names the alternatives if it does not get there.

Attributes

Source
HarmonicChainBarcode.scala
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def apply[CellT](stream: StratifiedCellStream[CellT, Double], maxDimension: Optional[Int] = ..., coefficients: Optional[Coefficients] = ..., includeZeroLength: Boolean = ..., orthogonalization: Orthogonalization = ...): PersistenceDiagram[CellT]

The harmonic chain barcode of stream in degrees 0..maxDimension (default: the stream's own degree limit if it has one, else 2, as for Persistence). The cells of dimension maxDimension + 1 are the ones that close classes of degree maxDimension, so a stream built with VietorisRips(points, maxDimension = k) holds them for k.

The harmonic chain barcode of stream in degrees 0..maxDimension (default: the stream's own degree limit if it has one, else 2, as for Persistence). The cells of dimension maxDimension + 1 are the ones that close classes of degree maxDimension, so a stream built with VietorisRips(points, maxDimension = k) holds them for k.

Attributes

Source
HarmonicChainBarcode.scala
def harmonicChains[CellT](stream: StratifiedCellStream[CellT, Double], dimension: Int, value: Double, coefficients: Coefficients, orthogonalization: Orthogonalization = ...): Vector[Chain[CellT, coefficients.C]]

A basis of the harmonic chains of degree dimension of the complex at filtration value value (all the cells of the stream with value at most value): as many chains as the Betti number there, each a cycle orthogonal to every boundary, in the order of their births. A lab hook for what the barcode follows: the chains the algorithm keeps alive after the last cell of that value (the order of the cells is insertionOrder). The chains' coefficients are coefficients.C: harmonicChains(stream, 1, 0.5, Coefficients.Rationals) has exact rational ones.

A basis of the harmonic chains of degree dimension of the complex at filtration value value (all the cells of the stream with value at most value): as many chains as the Betti number there, each a cycle orthogonal to every boundary, in the order of their births. A lab hook for what the barcode follows: the chains the algorithm keeps alive after the last cell of that value (the order of the cells is insertionOrder). The chains' coefficients are coefficients.C: harmonicChains(stream, 1, 0.5, Coefficients.Rationals) has exact rational ones.

Attributes

Source
HarmonicChainBarcode.scala
def insertionOrder[CellT](stream: StratifiedCellStream[CellT, Double], maxDimension: Int): Vector[(CellT, Double)]

The order in which apply inserts the cells of stream up to dimension maxDimension + 1: by filtration value, then dimension, then the position in the stream's own order of the dimension. Each cell comes with its filtration value.

The order in which apply inserts the cells of stream up to dimension maxDimension + 1: by filtration value, then dimension, then the position in the stream's own order of the dimension. Each cell comes with its filtration value.

Attributes

Source
HarmonicChainBarcode.scala
def ofOrder[CellT](order: Seq[(CellT, Double)], maxDimension: Int, coefficients: Optional[Coefficients] = ..., includeZeroLength: Boolean = ..., orthogonalization: Orthogonalization = ...): PersistenceDiagram[CellT]

The harmonic chain barcode of the filtration that inserts order, one cell at a time, each with its filtration value (which must not decrease along the order; a cell's faces must come before it). A bar lasts from the value of the cell that begins it to the value of the cell that ends it. Cells of dimension above maxDimension + 1 are ignored: they cannot change the harmonic chains of degrees up to maxDimension.

The harmonic chain barcode of the filtration that inserts order, one cell at a time, each with its filtration value (which must not decrease along the order; a cell's faces must come before it). A bar lasts from the value of the cell that begins it to the value of the cell that ends it. Cells of dimension above maxDimension + 1 are ignored: they cannot change the harmonic chains of degrees up to maxDimension.

Attributes

Source
HarmonicChainBarcode.scala