org.appliedtopology.tda4j

Members list

Type members

Experimental classlikes

object AlphaBackend

Attributes

Companion
enum
Experimental
true
Source
AlphaShapes.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type

Which alpha-complex construction AlphaShapes(points, backend) uses: BowyerWatson (incremental Delaunay with exact predicates, points spanning at most 4 dimensions), Helix (Delaunay by the Helix algorithm, any dimension), DQP (dual quadratic programs, any dimension, built only up to a radius), or Default (whichever the library expects to be fastest: see AlphaShapes.apply).

Which alpha-complex construction AlphaShapes(points, backend) uses: BowyerWatson (incremental Delaunay with exact predicates, points spanning at most 4 dimensions), Helix (Delaunay by the Helix algorithm, any dimension), DQP (dual quadratic programs, any dimension, built only up to a radius), or Default (whichever the library expects to be fastest: see AlphaShapes.apply).

Attributes

Companion
object
Experimental
true
Source
AlphaShapes.scala
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
open class AlphaComplexDQP(val space: PowerDistance, val maxPower: Double, val maxDimension: Int, cellsByDim: IndexedSeq[IndexedBuffer[Simplex[Int]]], tables: IndexedSeq[FaceTable], rowValues: IndexedSeq[DoubleRows], vertexValues: Array[Double], rowWitnesses: IndexedSeq[DoubleRows], vertexWitnesses: Array[Array[Double]], witnessWidth: Int)

A computed weighted alpha complex.

A computed weighted alpha complex.

Simplices are Simplex[Int] of site indices in increasing order. cells is in a valid filtration order: faces always precede cofaces.

Attributes

Companion
object
Experimental
true
Source
AlphaComplexDQP.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Experimental
true
Source
AlphaComplexDQP.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
class
Experimental
true
Source
AlphaComplexDQP.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class AlphaComplexDQPBuilder(val space: PowerDistance, val maxPower: Double, val maxDimension: Int, val settings: AlphaDQPSettings = ...)

Algorithm 1: compute the d-skeleton of Alpha(S, p, a1).

Algorithm 1: compute the d-skeleton of Alpha(S, p, a1).

Outer loop over dimension, inner loop over base vertex. B and U are built once per (dimension, vertex) rather than once per simplex, which is the only place ambient dimension enters the cost at all.

Attributes

Companion
object
Experimental
true
Source
AlphaComplexDQP.scala
Supertypes
class Object
trait Matchable
class Any
open class AlphaComplexDQPException(message: String) extends RuntimeException

Thrown when a quadratic program does not converge: a nearly degenerate configuration, which no fixed tolerance rules out (loosening AlphaDQPSettings may help). Building a complex catches it per candidate simplex and leaves that candidate out, so it reaches callers only from DualQP.solve directly.

Thrown when a quadratic program does not converge: a nearly degenerate configuration, which no fixed tolerance rules out (loosening AlphaDQPSettings may help). Building a complex catches it per candidate simplex and leaves that candidate out, so it reaches callers only from DualQP.solve directly.

Attributes

Experimental
true
Source
AlphaComplexDQP.scala
Supertypes
class RuntimeException
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
open class AlphaComplexDQPStream(val points: Array[Array[Double]], val alphaComplexDQP: AlphaComplexDQP) extends AlphaShapes

Wraps an ALREADY-BUILT AlphaComplexDQP (any space/maxPower/maxDimension, e.g. AlphaComplexDQP.dtm's DTM-weighted output, or a radius-truncated .weighted/.euclidean call) as an AlphaShapes stream -- the exact same iterateDimension/filtrationOrdering/filtrationValue shape AlphaShapeDQP uses for its own always-untruncated, always-unweighted build, just parameterized over a caller-supplied one instead of building a fresh untruncated AlphaComplexDQP.euclidean internally. points is needed only to satisfy AlphaShapes's own metricSpace contract (unused by homology engines, see that trait's doc); it must be the SAME points alphaComplexDQP was built from.

Wraps an ALREADY-BUILT AlphaComplexDQP (any space/maxPower/maxDimension, e.g. AlphaComplexDQP.dtm's DTM-weighted output, or a radius-truncated .weighted/.euclidean call) as an AlphaShapes stream -- the exact same iterateDimension/filtrationOrdering/filtrationValue shape AlphaShapeDQP uses for its own always-untruncated, always-unweighted build, just parameterized over a caller-supplied one instead of building a fresh untruncated AlphaComplexDQP.euclidean internally. points is needed only to satisfy AlphaShapes's own metricSpace contract (unused by homology engines, see that trait's doc); it must be the SAME points alphaComplexDQP was built from.

Attributes

Experimental
true
Source
AlphaComplexDQP.scala
Supertypes
class AlphaShapes
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
final case class AlphaDQPSettings(rankTolerance: Double = ..., feasibilityTolerance: Double = ..., zeroTolerance: Double = ..., equalityTolerance: Double = ..., maxIterationsPerQP: Int = ..., workingSetCapacity: Int = ..., enforceMonotonicity: Boolean = ..., parallel: Boolean = ..., verbose: Boolean = ..., rescueRankTolerance: Double = ..., keepWitnesses: Boolean = ...)

Settings of the quadratic programs. All tolerances are relative, so they survive rescaling the points.

Settings of the quadratic programs. All tolerances are relative, so they survive rescaling the points.

Value parameters

enforceMonotonicity

make each value at least the largest of its facets', and equal to it within solver accuracy (see clampMonotone): the values are monotone mathematically, and the persistence algorithms need it exactly.

equalityTolerance

consistency threshold for dependent equality constraints (relative to max|U|).

feasibilityTolerance

a constraint counts as violated when its slack exceeds this fraction of max|U|.

keepWitnesses

compute and keep the witness map Phi of every simplex (AlphaComplexDQP.witness), one row of the ambient dimension per simplex. The alpha streams (AlphaShapes with DQP) never read it and turn it off.

maxIterationsPerQP

iteration cap per QP; 0 means 20n + 200.

parallel

run the per-vertex loop on the common ForkJoinPool. Output is deterministic. Default: on, where there are threads to share the work (the JVM; a Scala.js program has one).

rankTolerance

a constraint counts as linearly dependent on the working set when its Schur complement falls below this fraction of B_jj. Values between 1e-7 and 1e-5 work; smaller lets nearly singular factorizations through (non-convergence or wrong answers), larger rejects real directions. A candidate ruled out for this reason gets a second attempt (rescueRankTolerance).

rescueRankTolerance

a candidate that rankTolerance rules out because of a small pivot is solved again with this smaller tolerance and kept if the multipliers it ends with satisfy the optimality conditions of the dual against the data. In high ambient dimension many valid simplices are that ill-conditioned. 0 turns the second attempt off.

verbose

print a line to stderr whenever a candidate is left out because its QP did not converge.

workingSetCapacity

max active set size; 0 means "ambient dimension + 2", which is a hard bound since the active rows live in R^m. Raise it only if you hit the corresponding exception.

zeroTolerance

threshold on multipliers in the ratio tests.

Attributes

Experimental
true
Source
AlphaComplexDQP.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
open class AlphaShapeDQP(val points: Array[Array[Double]], settings: AlphaDQPSettings = ...) extends AlphaShapes

Attributes

Experimental
true
Source
AlphaComplexDQP.scala
Supertypes
class AlphaShapes
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all

Alpha complexes of point clouds: AlphaShapes(points), or Persistence(points, complex = AlphaShapes).

Alpha complexes of point clouds: AlphaShapes(points), or Persistence(points, complex = AlphaShapes).

Attributes

Companion
class
Experimental
true
Source
AlphaShapes.scala
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class AlphaShapes extends LevelwiseSimplexStream[Int, Double], DoubleFiltration[Simplex[Int]]

Attributes

Companion
object
Experimental
true
Source
AlphaShapes.scala
Supertypes
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
Known subtypes
object Barcode

Stateless: every method here is a pure function of its arguments, so this is an object, not a class you instantiate per call (as it was before, Barcode[F, A]().method(...), with no state ever carried between the construction and the one call).

Stateless: every method here is a pure function of its arguments, so this is an object, not a class you instantiate per call (as it was before, Barcode[F, A]().method(...), with no state ever carried between the construction and the one call).

Attributes

Experimental
true
Source
Barcode.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Barcode.type
open class BarcodeBuilder[FiltrationT]()(using evidence$1: Ordering[FiltrationT])

Attributes

Experimental
true
Source
Barcode.scala
Supertypes
class Object
trait Matchable
class Any

Bottleneck and Wasserstein distances between persistence diagrams, by bipartite matching where each point may also be matched to its projection on the diagonal.

Bottleneck and Wasserstein distances between persistence diagrams, by bipartite matching where each point may also be matched to its projection on the diagonal.

The parameters follow GUDHI and Hera: groundNorm (their internal_p) measures one matched pair in the birth-death plane; order (their order, q in Kerber-Morozov-Nigmetov 2017) is the exponent the costs of all pairs are combined with. Wasserstein distance tends to bottleneck distance as order -> Infinity; use bottleneckDistance for that case.

'''Essential bars''' are matched only to essential bars, in order of birth (which is optimal for both distances). If the diagrams have different numbers of essential bars, the distance is Infinity.

Attributes

Experimental
true
Source
BarcodeDistance.scala
Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait BarcodeEndpoint[FiltrationT]

Attributes

Companion
object
Experimental
true
Source
Barcode.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class ClosedEndpoint[FiltrationT]
class NegativeInfinity[FiltrationT]
class OpenEndpoint[FiltrationT]
class PositiveInfinity[FiltrationT]

Attributes

Companion
trait
Experimental
true
Source
Barcode.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object BinaryIO

Shared little-endian binary primitives for the binary file formats this package reads/writes (Ripser's packed distance-matrix format, DIPHA's binary container format). Every such format is little-endian on disk regardless of host byte order -- confirmed directly against both projects' own source (Ripser's read reverses bytes only if (is_big_endian), i.e. the file itself is always little-endian; DIPHA's own README states "little-endian binary format" outright) -- so ByteBuffer.order(LITTLE_ENDIAN) is used unconditionally here rather than detecting host order, matching both.

Shared little-endian binary primitives for the binary file formats this package reads/writes (Ripser's packed distance-matrix format, DIPHA's binary container format). Every such format is little-endian on disk regardless of host byte order -- confirmed directly against both projects' own source (Ripser's read reverses bytes only if (is_big_endian), i.e. the file itself is always little-endian; DIPHA's own README states "little-endian binary format" outright) -- so ByteBuffer.order(LITTLE_ENDIAN) is used unconditionally here rather than detecting host order, matching both.

Attributes

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

An experiment (JVM only, #192): persistent cohomology of a Vietoris-Rips complex over F_p, degree by degree with clearing as Ripser does (degree 0 by union-find), on explicit coboundary matrices, reduced either sequentially or by edge blocks on a thread pool. Both reductions run the same column arithmetic on the same matrices.

An experiment (JVM only, #192): persistent cohomology of a Vietoris-Rips complex over F_p, degree by degree with clearing as Ripser does (degree 0 by union-find), on explicit coboundary matrices, reduced either sequentially or by edge blocks on a thread pool. Both reductions run the same column arithmetic on the same matrices.

Cells are ordered by block (a cell's first longest edge, by length, then smaller end, then larger end), then dimension, then the layered generator's order. A coface's block is never before its face's, so a column's entries lie in its own block or later ones, and only columns of the same block can have their pivot inside it. Phase 1 reduces each block's columns (in reverse order, as cohomology goes) by that block's columns only, while the pivot stays in the block: every pair it makes is one the sequential reduction makes. A column whose pivot leaves its block is deferred. Phase 2a reduces the deferred columns, in parallel, by the columns phase 1 paired (final, so only read); phase 2b finishes them one by one in order. A positive chunk merges consecutive blocks into units of at least that many columns, which is the chunk algorithm of Bauer, Kerber and Reininghaus with chunk boundaries on block boundaries (all the argument needs is that a unit is contiguous in the order).

java -cp $CP org.appliedtopology.tda4j.BlockParallelReduction      [trials] [seed] [p]

dataset is cube (uniform in the unit cube of R^d), torus or sphere (in R^3, with noise), or alpha: for the cloud's alpha complex instead (blocks by filtration value, fromStream; threshold ignored); method is seq, blocks-, chunks--, packed (PackedRipserCohomologyEngine, pairs only), packed-cocycles, verb (alpha: AlphaShapes, then Persistence), check (every method agrees) or dump (the points as CSV, for C++ Ripser). Each run builds the matrices once and reduces trials times; times are medians.

Attributes

Experimental
true
Source
BlockParallelReduction.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object BootstrapBand

A resampling confidence band for the bars of one degree, after Fasy, Lecci, Rinaldo, Wasserman, Balakrishnan and Singh, "Confidence sets for persistence diagrams" (Annals of Statistics 42, 2014).

A resampling confidence band for the bars of one degree, after Fasy, Lecci, Rinaldo, Wasserman, Balakrishnan and Singh, "Confidence sets for persistence diagrams" (Annals of Statistics 42, 2014).

Compute the diagram of the points, then of many resamples of them, and measure how far (in bottleneck distance) each resample's diagram is from the original. The 1 - alpha quantile of those distances is the band's width: a resample moves the diagram by at most width in 1 - alpha of the draws. A bar that persists longer than 2 * width cannot be matched to the diagonal by a perturbation of that size, so it is a feature that survives the resampling; a bar shorter than that could be one of the noise. Band.threshold is 2 * width, and diagram.longerThan(band.threshold) keeps the bars beyond it.

This is a resampling heuristic with a statistical reading, not a proof: the guarantee of the paper is for specific estimators and sampling models. Resampling with replacement (Resampling.Bootstrap) follows the paper's recipe. Resampling.Subsample draws fewer points without replacement and is cheaper; its distances are not rescaled to the full sample, so its band is wider than the bootstrap's (the conservative direction). Essential bars are left out of the comparison, so the band says nothing about them.

Attributes

Experimental
true
Source
BootstrapBand.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class BowyerWatsonDelaunay(pts: Array[Array[Double]], seed: Long = ...)(using factor: EpsilonFactor) extends DelaunayAlphaShapes

The Delaunay triangulation of a point cloud by Bowyer–Watson insertion, filtered as an alpha complex: for point clouds in 2 to 4 dimensions (of their affine span), the fast way to the whole alpha complex.

The Delaunay triangulation of a point cloud by Bowyer–Watson insertion, filtered as an alpha complex: for point clouds in 2 to 4 dimensions (of their affine span), the fast way to the whole alpha complex.

Points are inserted one at a time in a randomized, spatially sorted order; each insertion removes the simplices whose circumspheres contain the new point and fills the hole with simplices through it. The hull is handled with a vertex at infinity. Every geometric decision is exact (DelaunayPredicates), and points exactly on a circumsphere are decided by a perturbation that depends only on the points' order in the input, so the result is a valid triangulation for any input, degenerate ones (grids, cospherical points) included, and the same for every seed. Points that coincide exactly with an earlier one are joined to it by an edge of value 0.

Value parameters

pts

the points; their affine span must have dimension 1 to 4

seed

seeds the insertion order, which affects only the running time

Attributes

Experimental
true
Source
BowyerWatson.scala
Supertypes
class AlphaShapes
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
open class BowyerWatsonTriangulation(coordinates: Array[Array[Double]], seed: Long, checkEveryStep: Boolean = ...)

The triangulation behind BowyerWatsonDelaunay, on flat arrays: cell c has vertices vertex(c, 0 .. d) and, for each position i, the neighbouring cell across the facet opposite vertex(c, i). Finite cells are positively oriented. The vertex at infinity is the index n; a cell containing it (an "infinite" cell, one per hull facet) is stored so that replacing the vertex at infinity by a point beyond its hull facet gives a positive orientation, which makes "copy the cell and put the new point where the removed vertex was" correct for every cell.

The triangulation behind BowyerWatsonDelaunay, on flat arrays: cell c has vertices vertex(c, 0 .. d) and, for each position i, the neighbouring cell across the facet opposite vertex(c, i). Finite cells are positively oriented. The vertex at infinity is the index n; a cell containing it (an "infinite" cell, one per hull facet) is stored so that replacing the vertex at infinity by a point beyond its hull facet gives a positive orientation, which makes "copy the cell and put the new point where the removed vertex was" correct for every cell.

Attributes

Experimental
true
Source
BowyerWatson.scala
Supertypes
class Object
trait Matchable
class Any
open class BruteForce[VertexT](metricSpace: FiniteMetricSpace[VertexT]) extends SpatialQuery[VertexT]

Attributes

Experimental
true
Source
FiniteMetricSpace.scala
Supertypes
trait SpatialQuery[VertexT]
class Object
trait Matchable
class Any
object CSV

Generic delimited-text point clouds, distance matrices, and persistence diagrams -- fields split on , or any run of whitespace, so plain-whitespace-separated files (Dionysus/JavaPlex's own convention) parse with these same methods too.

Generic delimited-text point clouds, distance matrices, and persistence diagrams -- fields split on , or any run of whitespace, so plain-whitespace-separated files (Dionysus/JavaPlex's own convention) parse with these same methods too.

Attributes

Experimental
true
Source
CSV.scala
Supertypes
class Object
trait Matchable
class Any
Self type
CSV.type
object Cech extends PointCloudComplex

The Cech complex of a Euclidean point cloud; maxFiltrationValue is in Cech RADIUS units.

The Cech complex of a Euclidean point cloud; maxFiltrationValue is in Cech RADIUS units.

Attributes

Experimental
true
Source
Complexes.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Cech.type
open class CechCofaceSimplexStream(val euclideanMetricSpace: EuclideanMetricSpace, keepCriterion: PartialFunction[Simplex[Int], Boolean] = ..., maxFiltrationValue: Option[Double] = ..., parallelFiltrationValue: Boolean = ...) extends RipserCofaceSimplexStream

The Cech complex, built like RipserCofaceSimplexStream builds Vietoris-Rips: dimension by dimension, each simplex as a coface of an accepted simplex one dimension down. This finds every Cech simplex because the Cech complex is closed under faces. (The table lookup of the New-VR construction relies on a flag complex and is not used.)

The Cech complex, built like RipserCofaceSimplexStream builds Vietoris-Rips: dimension by dimension, each simplex as a coface of an accepted simplex one dimension down. This finds every Cech simplex because the Cech complex is closed under faces. (The table lookup of the New-VR construction relies on a flag complex and is not used.)

maxFiltrationValue is a radius.

Attributes

Experimental
true
Source
CechStream.scala
Supertypes
trait CofaceSimplexStream[Int, Double]
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all

The Cech filtration value of a simplex: the radius of the smallest ball containing its vertices (MinimumEnclosingBall). Values are cached, so a simplex has one value for the whole computation.

The Cech filtration value of a simplex: the radius of the smallest ball containing its vertices (MinimumEnclosingBall). Values are cached, so a simplex has one value for the whole computation.

Attributes

Experimental
true
Source
CechStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait Cell extends HasDimension

Attributes

Experimental
true
Source
Cell.scala
Supertypes
trait HasDimension
class Object
trait Matchable
class Any
Known subtypes
trait OrderedCell
abstract class CellDecoder[CellT]

Decodes the key of a packed cell (see PackedChain). A class rather than a function: an Int => CellT would box every key it is called with. Implement it to store chains of your own cells packed (Chain.packed).

Decodes the key of a packed cell (see PackedChain). A class rather than a function: an Int => CellT would box every key it is called with. Implement it to store chains of your own cells packed (Chain.packed).

Attributes

Experimental
true
Source
Chain.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class GridCubes
trait CellStream[CellT, FiltrationT] extends Filtration[CellT, FiltrationT], IterableOnce[CellT]

Attributes

Experimental
true
Source
SimplexStream.scala
Supertypes
trait IterableOnce[CellT]
trait Filtration[CellT, FiltrationT]
trait Filterable[FiltrationT]
class Object
trait Matchable
class Any
Show all
Known subtypes
open class CellularCohomologyEngine[CellT, CoefficientT, FiltrationT](val packSimplices: Boolean = ..., val useUnionFind: Boolean = ...)(using evidence$1: OrderedCell { type Self = CellT; }, evidence$2: Field { type Self = CoefficientT; }, evidence$3: Ordering[FiltrationT])

Persistent cohomology for any cell type (simplices, cubes, simplicial-set generators): the reduction of the coboundary matrix, following Bauer's Ripser (arXiv:1908.02518) without its Vietoris-Rips-specific shortcuts. Over a field the barcode is the same as the homology barcode; what this engine adds is cocycle representatives, and it works where the Ripser engines do not (Cech, alpha, cubical, simplicial sets, non-flag complexes).

Persistent cohomology for any cell type (simplices, cubes, simplicial-set generators): the reduction of the coboundary matrix, following Bauer's Ripser (arXiv:1908.02518) without its Vietoris-Rips-specific shortcuts. Over a field the barcode is the same as the homology barcode; what this engine adds is cocycle representatives, and it works where the Ripser engines do not (Cech, alpha, cubical, simplicial sets, non-flag complexes).

The coboundary is built by inverting the boundaries of the stream's cells, so the stream is read in full first. There is no maxDim: the stream decides the top degree. For degrees 0 .. k, pass a stream with cells up to dimension k + 1 (LimitedCofaceSimplexStream(stream, k + 1) for a coface stream) and ignore the degree-(k + 1) bars.

Representatives: every bar carries its V-column. For an essential bar it is a cocycle of the whole complex; for a finite bar its coboundary is the bar's reduced column, which is born at or after the bar's death, so it is a cocycle on the subcomplex before the death. coboundaryOfChain checks either.

Simplices with Int vertices (every complex the library builds: alpha, Čech, witness, Dowker, explicit streams) are reduced on flat arrays: each dimension's vertex tuples, a table from a tuple to its cell (the vertices side by side in one Long when they fit, else a hash of them), and each coboundary block as compressed columns of signs. Only a column that needs an addition becomes a Chain, and only the cells of the representatives returned are looked up again. The bars and representatives are exactly those of reducing the cells themselves.

Degree 0 is paired by union-find over the edges (the elder rule) when every edge is c·(v - u) between two cells of the stream, or has a boundary that vanishes (a loop): no vertex's coboundary is reduced then, and a bar's cocycle is the indicator of the component that dies. A complex with any other edge (a Morse complex can have one) reduces degree 0 like every other degree. The pairs and representatives are the same either way.

Value parameters

packSimplices

reduce simplices with Int vertices on flat arrays (see above). false reduces the cells themselves, with the same results, more slowly; reducesPacked tells which a stream gets.

useUnionFind

pair degree 0 by union-find where the complex allows (see above). false reduces the vertices' coboundaries, with the same results (for benchmarking and for checking the two against each other).

Attributes

Experimental
true
Source
Cohomology.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Experimental
true
Source
Homology.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class CellularHomologyEngine[CellT, CoefficientT, FiltrationT]

The naive persistence engine: the standard reduction algorithm, one cell at a time in filtration order. Each cell's boundary is reduced against the pivots recorded so far; a cell whose boundary reduces to zero opens a class, any other closes the class of its pivot. No clearing or other shortcuts: the reference the other engines are checked against.

The naive persistence engine: the standard reduction algorithm, one cell at a time in filtration order. Each cell's boundary is reduced against the pivots recorded so far; a cell whose boundary reduces to zero opens a class, any other closes the class of its pivot. No clearing or other shortcuts: the reference the other engines are checked against.

persistentHomology(stream) returns a cursor (HomologyState) that processes cells on demand: advanceTo(f), advanceFor(budget), advanceAll(), then diagramAt(f)/barcodeAt(f) for the diagram truncated at any f, with a representative cycle for every bar. The stream decides the top degree: cells of dimension k + 1 are needed for degree k, and the degree-(k + 1) bars of such a stream are incomplete.

Implementation note: chain arithmetic must order cells by the stream's filtration, so the RingModule instance is summoned inside HomologyState, where that ordering exists (a given fixes its own context when it is constructed).

Attributes

Companion
object
Experimental
true
Source
Homology.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class CubicalHomologyEngine[CoefficientT, FiltrationT]
class SimplicialHomologyEngine[VertexT, CoefficientT, FiltrationT]
open class CellularPersistenceInChunksEngine[CellT, CoefficientT](maxDim: Int = ...)(using evidence$1: OrderedCell { type Self = CellT; }, evidence$2: Field { type Self = CoefficientT; })

The chunks persistence engine: the clear-and-compress algorithm of Bauer, Kerber and Reininghaus ("Clear and compress: computing persistent homology in chunks", 2014), with degrees 0 and 1 by union-find. Reports degrees 0 .. maxDim (it reads cells up to dimension maxDim + 1 from the stream, so a stream built to that dimension is enough). The whole reduction runs on the first query; diagramAt(f)/barcodeAt(f) then give the diagram truncated at any f, with a representative cycle for every bar.

The chunks persistence engine: the clear-and-compress algorithm of Bauer, Kerber and Reininghaus ("Clear and compress: computing persistent homology in chunks", 2014), with degrees 0 and 1 by union-find. Reports degrees 0 .. maxDim (it reads cells up to dimension maxDim + 1 from the stream, so a stream built to that dimension is enough). The whole reduction runs on the first query; diagramAt(f)/barcodeAt(f) then give the diagram truncated at any f, with a representative cycle for every bar.

Attributes

Companion
object
Experimental
true
Source
Homology.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class CubicalPersistenceInChunksEngine[CoefficientT]
class PersistenceInChunksEngine[VertexT, CoefficientT]

Attributes

Companion
class
Experimental
true
Source
Homology.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object Chain

Attributes

Companion
class
Experimental
true
Source
Chain.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Chain.type
abstract class Chain[CellT, CoefficientT]

A formal sum of cells with coefficients in a field, kept in an order on the cells: its leading term, the pivot of a reduction, is the least cell. Made by Chain(...), Chain.from and arithmetic.

A formal sum of cells with coefficients in a field, kept in an order on the cells: its leading term, the pivot of a reduction, is the least cell. Made by Chain(...), Chain.from and arithmetic.

The storage is open to experiment: a subclass passes the order and the field to this constructor and implements entryIterator, its stored entries. Every other member has a default built on those two, which a storage may override for speed; reductions (Chain.reduceBy), arithmetic, boundary, equality and the engines use these members only. The library keeps chains in a heap (what Chain(...) and arithmetic make), and the grid engines keep their representatives packed in arrays.

Attributes

Companion
object
Experimental
true
Source
Chain.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class HeapChain[CellT, CoefficientT]
class PackedChain[CellT, CoefficientT]
open class CholeskyWorkspace(capacity: Int)

Maintains a Cholesky factor of B_W for the current working set W.

Maintains a Cholesky factor of B_W for the current working set W.

The working set is kept linearly independent, so B_W stays positive definite and a plain Cholesky suffices; DAQP uses LDL^T so that it can represent the singular step, we instead detect it via the Schur complement and restructure the working set immediately (see DualQP).

Appending is the standard bordered update; deleting removes a row of L and rotates the resulting extra superdiagonal away with Givens rotations, which is O(|W|²) rather than a refactorisation.

Attributes

Experimental
true
Source
AlphaComplexDQP.scala
Supertypes
class Object
trait Matchable
class Any

Circular coordinates (de Silva, Morozov, Vejdemo-Johansson, "Persistent Cohomology and Circular Coordinates", Discrete & Computational Geometry 45:737-759, 2011): a map from the points to the circle R/Z that represents a persistent H¹ class of the Vietoris-Rips complex.

Circular coordinates (de Silva, Morozov, Vejdemo-Johansson, "Persistent Cohomology and Circular Coordinates", Discrete & Computational Geometry 45:737-759, 2011): a map from the points to the circle R/Z that represents a persistent H¹ class of the Vietoris-Rips complex.

Pick a scale r inside the class's bar (see h1Bars). The class is then an essential class of the fixed complex K_r, the complex truncated at r; it is matched to the bar of the full computation with the same birth, since truncation never changes a birth. Its cocycle, computed over F_prime and lifted to the integers, is smoothed to the harmonic representative: g minimizing ||z - d0 g||² over the connected component of K_r carrying the class, solved by conjugate gradients on the normal equations with one vertex fixed at 0. The coordinate of a point is g(v) mod 1. The solve follows DREiMac's toroidalcoords.py.

There are two ways in. compute(metricSpace, r, ...) takes the points and does everything itself, on the Vietoris-Rips complex. CircularCoordinates(diagram, input, ...) takes a PersistenceDiagram you already have, of any complex and from any engine, together with what it was computed from, and reads the bar, its field and (when the diagram carries cocycles) its cocycle from the diagram.

'''Sparse coordinates''' (Perea, "Sparse Circular Coordinates via Principal Z-Bundles", Abel Symposia 15, 2020, arXiv:1809.09269) need only a few landmarks for any number of points. The loop is found on the nerve of the balls of radius r around the landmarks, which is the Dowker complex of the landmark-to-point distances; the harmonic coordinate g is computed on the landmarks, and a point x gets g(j) - sum_k phi_k(x) h(j, k), where j is its nearest landmark, h the harmonic cocycle and phi_k(x) proportional to max(r - d(x, l_k), 0). The cocycle condition on the nerve makes this independent of the choice of j, so the map is continuous. numLandmarks = n on h1Bars, compute and computeToroidal chooses it with n maxmin landmarks; sparse and sparseToroidal take a Dowker diagram and its relation, for landmarks or a cover of your own.

Attributes

Experimental
true
Source
CircularCoordinates.scala
Supertypes
class Object
trait Matchable
class Any
Self type
case class ClosedEndpoint[FiltrationT](value: FiltrationT)(using evidence$1: Ordering[FiltrationT]) extends BarcodeEndpoint[FiltrationT]

Attributes

Experimental
true
Source
Barcode.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait BarcodeEndpoint[FiltrationT]
class Object
trait Matchable
class Any
Show all
trait Coefficients

A coefficient field chosen at runtime: Coefficients(0) for real coefficients (Double, compared within precision), Coefficients(p) for Z/p with a prime p, and Coefficients.Rationals for exact rational numbers. import coefficients.given brings the field into scope; the coefficient type is the type member C. The library's default is FiniteField.DefaultPrime (17).

A coefficient field chosen at runtime: Coefficients(0) for real coefficients (Double, compared within precision), Coefficients(p) for Z/p with a prime p, and Coefficients.Rationals for exact rational numbers. import coefficients.given brings the field into scope; the coefficient type is the type member C. The library's default is FiniteField.DefaultPrime (17).

Attributes

Companion
object
Experimental
true
Source
Coefficients.scala
Supertypes
class Object
trait Matchable
class Any
object Coefficients

Attributes

Companion
trait
Experimental
true
Source
Coefficients.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
trait
Experimental
true
Source
SimplexStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait CofaceSimplexStream[VertexT, FiltrationT] extends LevelwiseSimplexStream[VertexT, FiltrationT]

A levelwise stream that builds dimension d + 1 from the simplices it kept in dimension d (their cofaces), caching the two dimensions it is working between. The machinery behind VietorisRips, Cech, Witness, Dowker, DtmRips and SparseRips; extend it (usually through RipserCofaceSimplexStream's filtrationValueOverride) to build a new filtered complex on the same coface loop. Any stream must keep the ordering contract of CellStream.

A levelwise stream that builds dimension d + 1 from the simplices it kept in dimension d (their cofaces), caching the two dimensions it is working between. The machinery behind VietorisRips, Cech, Witness, Dowker, DtmRips and SparseRips; extend it (usually through RipserCofaceSimplexStream's filtrationValueOverride) to build a new filtered complex on the same coface loop. Any stream must keep the ordering contract of CellStream.

Attributes

Companion
object
Experimental
true
Source
SimplexStream.scala
Supertypes
trait LevelwiseSimplexStream[VertexT, FiltrationT]
trait StratifiedCellStream[Simplex[VertexT], FiltrationT]
trait CellStream[Simplex[VertexT], FiltrationT]
trait IterableOnce[Simplex[VertexT]]
trait Filtration[Simplex[VertexT], FiltrationT]
trait Filterable[FiltrationT]
class Object
trait Matchable
class Any
Show all
Known subtypes
open class CofacetIterator[VertexT](val simplex: Simplex[VertexT], sparseMetricSpace: SparseMetricSpace[VertexT])(using evidence$1: Ordering[VertexT]) extends Iterator[VertexT]

******* Optimized Vietoris-Rips cofacet generation for fast coboundary computation *******

******* Optimized Vietoris-Rips cofacet generation for fast coboundary computation *******

Iterates the vertices w outside simplex for which simplex + w is a simplex of the sparse complex (every distance from w to a vertex of simplex finite in sparseMetricSpace), each once, in increasing order of the diameter of simplex + w. simplex must itself be a simplex of the sparse complex.

Attributes

Experimental
true
Source
Cofacets.scala
Supertypes
trait Iterator[VertexT]
trait IterableOnceOps[VertexT, Iterator, Iterator[VertexT]]
trait IterableOnce[VertexT]
class Object
trait Matchable
class Any
Show all

The conjugate gradient method for A x = b with A symmetric positive definite, given only as a function: the harmonic smoothing of CircularCoordinates solves a graph Laplacian system this way, never forming the matrix.

The conjugate gradient method for A x = b with A symmetric positive definite, given only as a function: the harmonic smoothing of CircularCoordinates solves a graph Laplacian system this way, never forming the matrix.

Attributes

Experimental
true
Source
ConjugateGradient.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object Cube extends CubeInstances

Attributes

Experimental
true
Source
Cubical.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Cube.type
open class CubeBoxes(shape: Array[Int])

Cubes of one grid built cheaply: a Vector[Int] holds its coordinates boxed, so every coordinate's box is made once per grid (doubled coordinates run up to 2 shape(i)), and the vector is made directly at its size. The result is an ordinary Vector[Int], equal to and hashing like Vector.tabulate's; a cube costs a vector and an array.

Cubes of one grid built cheaply: a Vector[Int] holds its coordinates boxed, so every coordinate's box is made once per grid (doubled coordinates run up to 2 shape(i)), and the vector is made directly at its size. The result is an ordinary Vector[Int], equal to and hashing like Vector.tabulate's; a cube costs a vector and an array.

Attributes

Experimental
true
Source
FastCubicalHomology.scala
Supertypes
class Object
trait Matchable
class Any

Cube's default instances, mixed into object Cube (implicit scope; see SimplexInstances).

Cube's default instances, mixed into object Cube (implicit scope; see SimplexInstances).

Attributes

Experimental
true
Source
CubicalOrderedCell.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Cube
open class CubicalGridStream(val shape: IndexedSeq[Int], val topCellValue: IndexedSeq[Int] => Double, val parallelFiltrationValue: Boolean = ..., val nanMask: Boolean = ...) extends StratifiedCellStream[Cube, Double], DoubleFiltration[Cube]

The cubical complex of a full rectangular grid, filtered by the values of its top cells (pixels, voxels): every other cube gets the minimum value of the top cells containing it, the sublevel-set convention of GUDHI, DIPHA and Perseus. A face is contained in every top cell its cofaces are, so the filtration is monotone. For superlevel sets, negate the values (what CubicalImage's sublevel = false does).

The cubical complex of a full rectangular grid, filtered by the values of its top cells (pixels, voxels): every other cube gets the minimum value of the top cells containing it, the sublevel-set convention of GUDHI, DIPHA and Perseus. A face is contained in every top cell its cofaces are, so the filtration is monotone. For superlevel sets, negate the values (what CubicalImage's sublevel = false does).

A top cell of value Double.NaN is masked: it is not in the complex. NaN has no sign and compares to nothing, so it means the same in a sublevel and a superlevel image. Every other cube takes the minimum over the UNMASKED top cells containing it, and is not in the complex either when all of them are masked: the complex is the closure of the unmasked top cells. Infinite values are ordinary values: a top cell of value +Infinity enters at +Infinity. With nanMask = false masks are off: a NaN value is an error, naming the pixel, when the values are first read.

shape(i) is the number of pixels along axis i. The complex has prod_i (2 shape(i) + 1) cells (totalCellCount): a 256x256 image has 513² = 263169.

Attributes

Companion
object
Experimental
true
Source
CubicalStream.scala
Supertypes
trait StratifiedCellStream[Cube, Double]
trait CellStream[Cube, Double]
trait IterableOnce[Cube]
trait Filtration[Cube, Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Companion
class
Experimental
true
Source
CubicalStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
class
Experimental
true
Source
Homology.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class CubicalHomologyEngine[CoefficientT, FiltrationT]()(using evidence$1: Field { type Self = CoefficientT; }, evidence$2: Ordering[FiltrationT]) extends CellularHomologyEngine[Cube, CoefficientT, FiltrationT]

The naive engine (CellularHomologyEngine) on cubes.

The naive engine (CellularHomologyEngine) on cubes.

Attributes

Companion
object
Experimental
true
Source
Homology.scala
Supertypes
class CellularHomologyEngine[Cube, CoefficientT, FiltrationT]
class Object
trait Matchable
class Any
object CubicalImage

Cubical complexes of images and voxel grids. Every array constructor reduces to fromFlatArray: values in row-major order (last axis fastest) and a shape.

Cubical complexes of images and voxel grids. Every array constructor reduces to fromFlatArray: values in row-major order (last axis fastest) and a shape.

sublevel = true (the default, as in GUDHI, DIPHA and Perseus) filters by the values; sublevel = false by the negated values, so bars of a superlevel filtration are reported in negated units. Voxel data of any file format is loaded into an array first. A pixel of value Double.NaN is masked (missing data): it is not in the complex, in a sublevel and a superlevel image alike (NaN has no sign). Infinite values are ordinary values: +Infinity enters after every finite value in a sublevel image, and before them in a superlevel one (negated to -Infinity). Every array constructor takes nanMask = false to turn masks off: a NaN pixel is then an error, naming the pixel.

Attributes

Experimental
true
Source
CubicalImage.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class CubicalLab(characteristic: Int, precision: Double = ...) extends Lab

The cubical lab: Lab plus chain arithmetic on Chain[Cube, CoefficientT] and a Cube -> Chain widening (and no simplex conveniences). import CubicalLab.F17.{*, given}.

The cubical lab: Lab plus chain arithmetic on Chain[Cube, CoefficientT] and a Cube -> Chain widening (and no simplex conveniences). import CubicalLab.F17.{*, given}.

Attributes

Companion
object
Experimental
true
Source
package.scala
Supertypes
class Lab
class Object
trait Matchable
class Any
Known subtypes
object F17
object F2
object F3
object Reals
object CubicalLab

Prebuilt cubical labs: import CubicalLab.F17.{*, given}.

Prebuilt cubical labs: import CubicalLab.F17.{*, given}.

Attributes

Companion
class
Experimental
true
Source
package.scala
Supertypes
class Object
trait Matchable
class Any
Self type
CubicalLab.type
open class CubicalPersistenceInChunksEngine[CoefficientT](maxDim: Int = ...)(using evidence$1: Field { type Self = CoefficientT; }) extends CellularPersistenceInChunksEngine[Cube, CoefficientT]

The chunks engine (CellularPersistenceInChunksEngine) on cubes.

The chunks engine (CellularPersistenceInChunksEngine) on cubes.

Attributes

Experimental
true
Source
Homology.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Experimental
true
Source
AlphaShapes.scala
Supertypes
class Object
trait Matchable
class Any
Self type
abstract class DelaunayAlphaShapes(using epsilon: Epsilon) extends AlphaShapes, FlatLayerStream

An alpha complex read off a Delaunay triangulation of points: the faces of the top-dimensional simplices, with alpha values computed top-down (see valueOf). A subclass supplies the triangulation (topSimplices, distinct) and the value of each top simplex (topValue, its circumradius); HelixDelaunay is one. FastAlphaHomologyEngine works on any of them.

An alpha complex read off a Delaunay triangulation of points: the faces of the top-dimensional simplices, with alpha values computed top-down (see valueOf). A subclass supplies the triangulation (topSimplices, distinct) and the value of each top simplex (topValue, its circumradius); HelixDelaunay is one. FastAlphaHomologyEngine works on any of them.

Attributes

Companion
object
Experimental
true
Source
AlphaShapes.scala
Supertypes
class AlphaShapes
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
Known subtypes
open class DelaunayPredicates(points: Array[Array[Double]])

Exact geometric predicates for Delaunay triangulation in dimensions 2 to 4: the sign of an orientation determinant and of an in-sphere determinant, each computed in floating point first and, when the result is too close to zero for the floating-point error bound, again in exact arithmetic (BigDecimal: a double is a binary fraction, so sums and products of doubles are exact there). In-sphere ties (a point exactly on a circumsphere) are broken by a symbolic perturbation of the lifted coordinate that depends only on the points' indices, so the result is the Delaunay triangulation of an infinitesimally perturbed point set: unique, whatever the insertion order.

Exact geometric predicates for Delaunay triangulation in dimensions 2 to 4: the sign of an orientation determinant and of an in-sphere determinant, each computed in floating point first and, when the result is too close to zero for the floating-point error bound, again in exact arithmetic (BigDecimal: a double is a binary fraction, so sums and products of doubles are exact there). In-sphere ties (a point exactly on a circumsphere) are broken by a symbolic perturbation of the lifted coordinate that depends only on the points' indices, so the result is the Delaunay triangulation of an infinitesimally perturbed point set: unique, whatever the insertion order.

Determinants are expanded over permutations, which is cheap up to 5x5 (in-sphere in 4-D) and grows as n! beyond.

Attributes

Experimental
true
Source
DelaunayPredicates.scala
Supertypes
class Object
trait Matchable
class Any
case class DelaunaySimplex(simplex: Simplex[Int], circumsphere: Hypersphere)

Attributes

Experimental
true
Source
AlphaShapes.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final class DenseMatrix

A matrix of Doubles, stored by rows, with the two decompositions the geometric code needs: svd (singular values, null directions, least squares solutions) and lu (square solves). Small and dense on purpose: it serves the matrices of a handful of points in a few dimensions, and the matrices of finitely presented persistence modules; for the large sparse reductions of persistent homology see Chain.

A matrix of Doubles, stored by rows, with the two decompositions the geometric code needs: svd (singular values, null directions, least squares solutions) and lu (square solves). Small and dense on purpose: it serves the matrices of a handful of points in a few dimensions, and the matrices of finitely presented persistence modules; for the large sparse reductions of persistent homology see Chain.

Like DenseVector a matrix is a value: it never changes, and equal entries mean equal matrices.

Attributes

Companion
object
Experimental
true
Source
DenseMatrix.scala
Supertypes
class Object
trait Matchable
class Any
object DenseMatrix

Attributes

Companion
class
Experimental
true
Source
DenseMatrix.scala
Supertypes
class Object
trait Matchable
class Any
Self type
final class DenseVector

A vector of Doubles of fixed length: the point and direction type of the geometric code (AlphaShapes.Point, Hyperplane, Hypersphere) and the right-hand side of DenseMatrix solves.

A vector of Doubles of fixed length: the point and direction type of the geometric code (AlphaShapes.Point, Hyperplane, Hypersphere) and the right-hand side of DenseMatrix solves.

A vector is a value. It never changes, two vectors with the same entries are equal and have the same hash code (so a case class holding one, such as Hypersphere, can be a key of a hash set), and 0.0 and -0.0 are the same entry. NaN is equal to itself, so a vector with a NaN entry is still equal to a copy of itself.

Attributes

Companion
object
Experimental
true
Source
DenseVector.scala
Supertypes
class Object
trait Matchable
class Any
object DenseVector

Attributes

Companion
class
Experimental
true
Source
DenseVector.scala
Supertypes
class Object
trait Matchable
class Any
Self type
case class DiagramPoint(birth: Double, death: Double)

A diagram point extracted from a PersistenceBar's (lower, upper) endpoints as plain Doubles, shared by BarcodeDistance and Vectorization so both apply the same finite-birth requirement and essential-bar test rather than two independently-drifting copies.

A diagram point extracted from a PersistenceBar's (lower, upper) endpoints as plain Doubles, shared by BarcodeDistance and Vectorization so both apply the same finite-birth requirement and essential-bar test rather than two independently-drifting copies.

Attributes

Companion
object
Experimental
true
Source
DiagramPoint.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object DiagramPoint

Attributes

Companion
class
Experimental
true
Source
DiagramPoint.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object Dipha

DIPHA's binary formats: little-endian, each file starting with the magic number 8067171840 and an Int64 file type. DIPHA images list the first axis fastest, the opposite of CubicalImage.fromFlatArray; the readers and writers convert.

DIPHA's binary formats: little-endian, each file starting with the magic number 8067171840 and an Int64 file type. DIPHA images list the first axis fastest, the opposite of CubicalImage.fromFlatArray; the readers and writers convert.

Attributes

Experimental
true
Source
Dipha.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Dipha.type
open class DirectedFlagStream(val n: Int, edges: Iterable[(Int, Int, Double)], val maxDimension: Int, val maxFiltrationValue: Double = ..., vertexValue: Int => Double = ...) extends StratifiedCellStream[DirectedSimplex, Double], DoubleFiltration[DirectedSimplex]

The directed flag complex of a weighted directed graph (the construction of Flagser, Luetgehetmann, Govc, Smith and Levi 2020; Reimann et al. 2017 for the clique complex of a neural network): its cells are the ordered tuples of vertices (v0, ..., vk) such that every edge vi -> vj with i < j is present, and a cell enters at the largest weight of those edges (or of its vertices, which enter at vertexValue, 0 by default).

The directed flag complex of a weighted directed graph (the construction of Flagser, Luetgehetmann, Govc, Smith and Levi 2020; Reimann et al. 2017 for the clique complex of a neural network): its cells are the ordered tuples of vertices (v0, ..., vk) such that every edge vi -> vj with i < j is present, and a cell enters at the largest weight of those edges (or of its vertices, which enter at vertexValue, 0 by default).

A directed cycle a -> b -> c -> a is a hole: no tuple contains all three, so the three edges bound nothing. The same three vertices with a -> c in place of c -> a span the filled triangle (a, b, c). An undirected graph (both directions present) gives many more cells than its clique complex, one for every ordering of every clique.

val stream = DirectedFlagStream(4, Seq((0, 1, 1.0), (1, 2, 1.0), (2, 0, 1.0)), maxDimension = 1)
Persistence(stream).bettiNumbers   // Vector(1, 1): a loop

The complex is built for homological degrees 0 .. maxDimension (it holds the cells up to dimension maxDimension + 1), and every cell is held in memory.

Value parameters

edges

(from, to, weight), each ordered pair once; a pair and its reverse may both be present

maxFiltrationValue

cells entering later than this are left out

Attributes

Experimental
true
Source
DirectedFlagStream.scala
Supertypes
trait CellStream[DirectedSimplex, Double]
trait IterableOnce[DirectedSimplex]
trait Filtration[DirectedSimplex, Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Experimental
true
Source
DirectedSimplex.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class DirectedSimplex(vertices: Vector[Int])

An ordered simplex (v0, v1, ..., vk): distinct vertices in a fixed order, a cell of the directed flag complex of a directed graph (the cliques whose edges all point from earlier to later vertices). Unlike a Simplex, the order matters: (0, 1) and (1, 0) are different edges. Its faces are the tuples with one vertex removed, with the sign (-1)^i for removing position i.

An ordered simplex (v0, v1, ..., vk): distinct vertices in a fixed order, a cell of the directed flag complex of a directed graph (the cliques whose edges all point from earlier to later vertices). Unlike a Simplex, the order matters: (0, 1) and (1, 0) are different edges. Its faces are the tuples with one vertex removed, with the sign (-1)^i for removing position i.

Attributes

Companion
object
Experimental
true
Source
DirectedSimplex.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object DiscreteMorse

Discrete Morse theory on a filtered complex: apply finds a matching that respects the filtration (a pair enters at one value) and returns the MorseComplex.

Discrete Morse theory on a filtered complex: apply finds a matching that respects the filtration (a pair enters at one value) and returns the MorseComplex.

val rips = VietorisRips(points, maxDimension = 2)
val morse = DiscreteMorse(rips)
morse.critical.size                      // far fewer cells than `rips`
Persistence(morse.stream, maxDimension = 2)   // the same bars as Persistence(rips, maxDimension = 2)

The matching is made level by level, a level being the cells that enter at one value, by elementary collapses (Strategy.Reduction: a cell with exactly one coface in the level, paired with it) or by elementary coreductions (Strategy.Coreduction: a cell with exactly one face in the level, paired with it), and when neither applies the cell of highest (respectively lowest) dimension is left critical. Pairs inside one level are acyclic, and a gradient path never goes back up in the filtration, so the matching is acyclic as a whole; the pairs are the apparent pairs of Ripser and more.

Attributes

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

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.

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
Supertypes
class Object
trait Matchable
class Any
Self type

The empirical distance to measure (Chazal, Cohen-Steiner, Mérigot, "Geometric inference for probability measures", Found. Comput. Math. 11, 2011) with k neighbours:

The empirical distance to measure (Chazal, Cohen-Steiner, Mérigot, "Geometric inference for probability measures", Found. Comput. Math. 11, 2011) with k neighbours:

f(x) = ( (1/k) sum over the k nearest neighbours y of x of d(x, y)^q )^(1/q)

As in GUDHI, x counts among its own neighbours (so k = 1 gives f = 0) and q defaults to 2.

The SpatialQuery chooses the nearest-neighbour search. BruteForce works for any distances; VantagePointQuery requires the triangle inequality, which an ExplicitMetricSpace does not check.

Attributes

Experimental
true
Source
DistanceToMeasure.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object DoubledGrid

Iteration over the doubled grid of a cubical grid (KMM encoding: coordinate 2a is the point a, 2a + 1 the interval [a, a + 1]), one prefix (the coordinates of every axis but the last) at a time, so a caller can walk the last axis in a tight loop and skip the prefixes that hold none of the cells it wants.

Iteration over the doubled grid of a cubical grid (KMM encoding: coordinate 2a is the point a, 2a + 1 the interval [a, a + 1]), one prefix (the coordinates of every axis but the last) at a time, so a caller can walk the last axis in a tight loop and skip the prefixes that hold none of the cells it wants.

Attributes

Experimental
true
Source
GridRanks.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object Dowker

The Dowker complex of a relation R: L x W -> [0, Infinity] (vertices are the rows). dual = true gives the complex on the other side (the transpose relation), which Dowker duality makes homotopy equivalent.

The Dowker complex of a relation R: L x W -> [0, Infinity] (vertices are the rows). dual = true gives the complex on the other side (the transpose relation), which Dowker duality makes homotopy equivalent.

Attributes

Experimental
true
Source
Complexes.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Dowker.type

Attributes

Companion
class
Experimental
true
Source
DowkerStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class DowkerCofaceSimplexStream(val geometry: DowkerGeometry, val maxFiltrationValue: Double = ..., keepCriterion: PartialFunction[Simplex[Int], Boolean] = ...) extends RipserCofaceSimplexStream

The filtered Dowker complex on the rows of geometry.relation (vertex i is row i); dual gives the one on the columns. maxFiltrationValue defaults to Infinity: a relation has no enclosing radius to truncate at.

The filtered Dowker complex on the rows of geometry.relation (vertex i is row i); dual gives the one on the columns. maxFiltrationValue defaults to Infinity: a relation has no enclosing radius to truncate at.

Attributes

Companion
object
Experimental
true
Source
DowkerStream.scala
Supertypes
trait CofaceSimplexStream[Int, Double]
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all

DowkerGeometry.filtrationValue, memoized. Vertices get their own (generally nonzero) value.

DowkerGeometry.filtrationValue, memoized. Vertices get their own (generally nonzero) value.

Attributes

Experimental
true
Source
DowkerStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class DowkerGeometry(val relation: Array[Array[Double]])

The filtered Dowker complex of a relation R: L x W -> [0, Infinity] between two finite sets (C. H. Dowker, "Homology groups of relations", Ann. of Math. 56 (1952); filtered as in Chowdhury and Mémoli, "A functorial Dowker theorem and persistent homology of asymmetric networks", 2018). A set sigma of rows is a simplex at t when one witness w sees all of it by then:

The filtered Dowker complex of a relation R: L x W -> [0, Infinity] between two finite sets (C. H. Dowker, "Homology groups of relations", Ann. of Math. 56 (1952); filtered as in Chowdhury and Mémoli, "A functorial Dowker theorem and persistent homology of asymmetric networks", 2018). A set sigma of rows is a simplex at t when one witness w sees all of it by then:

f(sigma) = min_w max_{x in sigma} R(x, w)

R need not come from a metric. The unfiltered Dowker complex is the case R(x, w) in {0, Infinity} (DowkerGeometry.fromBoolean). With R the landmark-to-witness distances (WitnessGeometry.D) it is the Čech complex of the landmarks with the balls' common point required to be a witness. That is contained in every witness complex but is none of them: the lazy witness complex with nu = 0 is its flag complex (the same edges).

The filtration is monotone (f(tau) <= f(sigma) for tau a face of sigma, since the max over a subset is smaller for every w), vertices have values min_w R(x, w) that are generally nonzero, and the complex is not a flag complex, so the Ripser engines do not apply (MATLAB and the CLI also do not offer chunks for relations).

'''Duality''': the complexes of R (on the rows) and of its transpose (dual, on the columns) are homotopy equivalent at every t, and their persistence modules are isomorphic, so their barcodes agree. This holds for the barcodes without zero-length bars, the default: with includeZeroLength = true the two sides differ, since each vertex contributes an H₀ birth and the sides have different numbers of vertices.

Attributes

Companion
object
Experimental
true
Source
DowkerStream.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Experimental
true
Source
DowkerStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object DtmRips

The distance-to-measure-weighted Rips complex (Anai et al.); p is 1.0 (default) or 2.0.

The distance-to-measure-weighted Rips complex (Anai et al.); p is 1.0 (default) or 2.0.

Attributes

Experimental
true
Source
Complexes.scala
Supertypes
class Object
trait Matchable
class Any
Self type
DtmRips.type
open class DtmRipsSimplexStream(val reified: DtmMetricSpace, keepCriterion: PartialFunction[Simplex[Int], Boolean] = ..., maxFiltrationValue: Option[Double] = ..., parallelFiltrationValue: Boolean = ...) extends RipserCofaceSimplexStream

The DTM-filtration of Anai, Chazal, Glisse, Ike, Lecci, Rouvreau, Saulnier and Wasserman, "DTM-based filtrations" (arXiv:1811.04757, Prop. 3.5), a weighted Rips filtration with weights f(x) the distance to measure (DistanceToMeasure). Values are diameters, as in Vietoris-Rips and GUDHI; with f = 0 (as for k = 1) this is the Vietoris-Rips filtration. For p = 1 it agrees with GUDHI's DTMRipsComplex.

The DTM-filtration of Anai, Chazal, Glisse, Ike, Lecci, Rouvreau, Saulnier and Wasserman, "DTM-based filtrations" (arXiv:1811.04757, Prop. 3.5), a weighted Rips filtration with weights f(x) the distance to measure (DistanceToMeasure). Values are diameters, as in Vietoris-Rips and GUDHI; with f = 0 (as for k = 1) this is the Vietoris-Rips filtration. For p = 1 it agrees with GUDHI's DTMRipsComplex.

p is the ball-radius exponent of Def. 3.1 (not the exponent q of the distance to measure), 1 or 2:

  • p = 1: t(f_x, f_y, d) = max(f_x, f_y, (d + f_x + f_y) / 2), as in GUDHI;
  • p = 2: t = max(f_x, f_y, sqrt(u² + f_x²)) with u = (d² + f_y² - f_x²) / (2d) when |f_y² - f_x²| <= d², and max(f_x, f_y) otherwise (one ball contains the other).

A flag complex on the weighted distances 2 t, with vertex x born at 2 f(x). maxFiltrationValue defaults to the minimum enclosing radius of the weighted distances, which is at least every vertex's birth and beyond which the complex is a cone. Vertices are born at nonzero values, so the Ripser engines do not apply.

Attributes

Companion
object
Experimental
true
Source
DtmRipsStream.scala
Supertypes
trait CofaceSimplexStream[Int, Double]
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Experimental
true
Source
DtmRipsStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class DualQP(val n: Int, workingSetCapacity: Int, settings: AlphaDQPSettings)

Solves

Solves

maximise d(lambda) = -1/2 lambda^t B lambda + U^t lambda subject to lambda_i >= 0 for i not in J

which is the Lagrangian dual of Eq. (9) with H = I. Optimum equals the primal optimum c* = 1/2 ||y* - x||^2; the primal solution is recovered from the KKT conditions (12) as y* = x - sum_i lambda_i (x_i - x).

Reused across every candidate simplex sharing the same base vertex x -- only J changes, which is exactly the observation in the paper that lets B and U be assembled once per vertex rather than once per simplex.

The instance is stateful and not thread safe; give each worker its own.

Attributes

Experimental
true
Source
AlphaComplexDQP.scala
Supertypes
class Object
trait Matchable
class Any
object EdgeCollapse

Edge collapse of a Vietoris-Rips filtration (Boissonnat and Pritam, "Edge Collapse and Persistence of Flag Complexes", SoCG 2020; Glisse and Pritam, "Swap, Shift and Trim to Edge Collapse a Filtration", SoCG 2022): a smaller weighted graph whose flag complex has the same persistent homology at every scale, computed from the graph alone.

Edge collapse of a Vietoris-Rips filtration (Boissonnat and Pritam, "Edge Collapse and Persistence of Flag Complexes", SoCG 2020; Glisse and Pritam, "Swap, Shift and Trim to Edge Collapse a Filtration", SoCG 2022): a smaller weighted graph whose flag complex has the same persistent homology at every scale, computed from the graph alone.

An edge {u, v} is dominated by a vertex w when every common neighbour of u and v is a neighbour of w; removing a dominated edge (and the simplices containing it) from a flag complex is a collapse. Over a filtration, an edge's entry is postponed to the last scale at which it is still dominated, or the edge is removed if it stays dominated to the end. This is a port of GUDHI's single pass (Flag_complex_edge_collapser.h): edges in decreasing order of their original value, each decided once against the graph as it stands. The order matters: deciding the edges independently and iterating to a fixed point removes too much. One pass is not necessarily minimal, and collapsing the output again may shrink it further.

At every scale the collapsed complex is a subcomplex of the original, so a representative computed on it is a representative of the same class in the original complex.

Attributes

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

The collapsed graph as a metric space on the same vertices: Infinity for a removed pair. Not a metric (the triangle inequality fails where edges were removed), so use it only with the combinatorial Vietoris-Rips constructions. Its minimumEnclosingRadius is the bound the collapse used, so the default cutoff downstream is the same as for the original space.

The collapsed graph as a metric space on the same vertices: Infinity for a removed pair. Not a metric (the triangle inequality fails where edges were removed), so use it only with the combinatorial Vietoris-Rips constructions. Its minimumEnclosingRadius is the bound the collapse used, so the default cutoff downstream is the same as for the original space.

Attributes

Experimental
true
Source
EdgeCollapseStream.scala
Supertypes
trait FiniteMetricSpace[Int]
class Object
trait Matchable
class Any
object Endpoints

Shared textual infinite-endpoint parsing/formatting (inf/-inf/infinity, any case), used by every text-based persistence-diagram format in this package (CSV, Gudhi). Dipha's binary persistence-diagram format uses its own numeric essential-class convention instead (a negative dimension field) and doesn't need this.

Shared textual infinite-endpoint parsing/formatting (inf/-inf/infinity, any case), used by every text-based persistence-diagram format in this package (CSV, Gudhi). Dipha's binary persistence-diagram format uses its own numeric essential-class convention instead (a negative dimension field) and doesn't need this.

Attributes

Experimental
true
Source
Endpoints.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Endpoints.type
open class EnumeratingCofaceSimplexStream(val metricSpace: FiniteMetricSpace[Int], var keepCriterion: PartialFunction[Simplex[Int], Boolean] = ..., maxFiltrationValue: Option[Double] = ..., filtrationValueOverride: Option[PartialFunction[Simplex[Int], Double]] = ...) extends CofaceSimplexStream[Int, Double], DoubleFiltration[Simplex[Int]]

Vietoris-Rips (or, with filtrationValueOverride, any filtration on the same vertex set that is monotone along faces), each dimension enumerated in full by SimplexIndexing's combinatorial number system and filtered by keepCriterion and maxFiltrationValue. What VietorisRips chooses between, with RipserCofaceSimplexStream.

Vietoris-Rips (or, with filtrationValueOverride, any filtration on the same vertex set that is monotone along faces), each dimension enumerated in full by SimplexIndexing's combinatorial number system and filtered by keepCriterion and maxFiltrationValue. What VietorisRips chooses between, with RipserCofaceSimplexStream.

Enumerating every vertex set of a dimension holds only while there are at most Int.MaxValue of them (a Range of indices); RipserCofaceSimplexStream, the default, builds each dimension from the cofaces of the cells it kept and has no such limit. The tie-break of filtrationOrdering is SimplexIndexing.colexOrdering, which has none either.

Attributes

Experimental
true
Source
SimplexStream.scala
Supertypes
trait CofaceSimplexStream[Int, Double]
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
Known subtypes
final case class Epsilon(epsilon: Double)

An absolute numerical tolerance of the triangulation's geometric tests (near-zero singular values and circumsphere margins), in the units of the coordinates. The triangulations (HelixDelaunay, BowyerWatsonDelaunay) take an EpsilonFactor instead and derive this from the extent of their points, so that a barcode does not depend on the units of the data.

An absolute numerical tolerance of the triangulation's geometric tests (near-zero singular values and circumsphere margins), in the units of the coordinates. The triangulations (HelixDelaunay, BowyerWatsonDelaunay) take an EpsilonFactor instead and derive this from the extent of their points, so that a barcode does not depend on the units of the data.

Attributes

Experimental
true
Source
AlphaShapes.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class EpsilonFactor(factor: Double)

The tolerance of the triangulation's geometric tests as a fraction of the extent of the point set (its largest coordinate range), so the same cloud in metres or in micrometres gives the same complex. EpsilonFactor(1e-5) is the default, found without an import; pass a given EpsilonFactor to change it. The tolerance is factor * extent (an extent of 0, a single point, counts as 1).

The tolerance of the triangulation's geometric tests as a fraction of the extent of the point set (its largest coordinate range), so the same cloud in metres or in micrometres gives the same complex. EpsilonFactor(1e-5) is the default, found without an import; pass a given EpsilonFactor to change it. The tolerance is factor * extent (an extent of 0, a single point, counts as 1).

Attributes

Companion
object
Experimental
true
Source
AlphaShapes.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object EpsilonFactor

Attributes

Companion
class
Experimental
true
Source
AlphaShapes.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object Erf

The error function erf(x) = 2/sqrt(pi) * integral_0^x exp(-t^2) dt and its complement erfc(x) = 1 - erf(x).

The error function erf(x) = 2/sqrt(pi) * integral_0^x exp(-t^2) dt and its complement erfc(x) = 1 - erf(x).

Computed by W. J. Cody's rational Chebyshev approximations ("Rational Chebyshev approximations for the error function", Mathematics of Computation 23, 1969): one in x on |x| <= 0.46875, one in exp(-x^2) times a rational function of x up to 4, and one in 1/x^2 beyond. erf is accurate to 4e-16 absolute (a few units in the last place), erfc to a relative 2e-15 out to where it underflows (near x = 26.5). erf is exactly odd and exactly +-1 from |x| = 6.

Attributes

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

Attributes

Companion
class
Experimental
true
Source
FiniteMetricSpace.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class EuclideanMetricSpace(coordinates: Array[Array[Double]], val cacheDistances: Boolean = ...) extends FiniteMetricSpace[Int]

The Euclidean distances between the rows of coordinates (all of the same length, all entries finite).

The Euclidean distances between the rows of coordinates (all of the same length, all entries finite).

The space owns a snapshot of the coordinates, taken on construction: changing the arrays passed in, or an array returned by pts or point, changes neither the distances nor the minimum enclosing radius nor the vantage-point tree. Ragged or non-finite input is rejected, naming the first offending point.

Value parameters

cacheDistances

compute all pairwise distances on first use and look them up afterwards (default true). That is n^2 doubles, about 8 MB at 1,000 points and 512 MB at 8,192, so the cache is only kept up to EuclideanMetricSpace.MaxCachedPoints points; above that every distance is computed when asked for. Pass false to compute every distance on demand at any size. Distances are looked up many times per pair during a Vietoris-Rips computation, so the cache usually pays off where it fits.

Attributes

Companion
object
Experimental
true
Source
FiniteMetricSpace.scala
Supertypes
trait FiniteMetricSpace[Int]
class Object
trait Matchable
class Any
final case class EulerCharacteristicCurve(scales: IndexedSeq[Double], values: IndexedSeq[Long])

The Euler characteristic of a filtered complex as a function of the scale: the number of vertices, minus the edges, plus the triangles, ... of the cells with filtration value at most t. It is a step function, so the curve keeps the scales where it steps and the value from there on.

The Euler characteristic of a filtered complex as a function of the scale: the number of vertices, minus the edges, plus the triangles, ... of the cells with filtration value at most t. It is a step function, so the curve keeps the scales where it steps and the value from there on.

val curve = EulerCharacteristicCurve(points)               // Vietoris-Rips, simplices up to dimension 2
curve(0.3)                                                 // the Euler characteristic at scale 0.3
curve.sample(0.0, 1.0, 50)                                 // 50 evenly spaced samples

A vectorization that needs no persistence: EulerCharacteristicCurve.apply counts the cliques of every edge's lens graph, so it stores no simplices and sorts nothing.

Value parameters

scales

The scales where the curve changes, strictly increasing; for a point cloud the first is 0.0, where the vertices appear.

values

values(i) is the Euler characteristic from scales(i) up to (not including) scales(i + 1).

Attributes

Companion
object
Experimental
true
Source
EulerCharacteristicCurve.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Experimental
true
Source
EulerCharacteristicCurve.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Attributes

Companion
class
Experimental
true
Source
CubicalStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class ExplicitCubicalStream(val filtrationValues: Map[Cube, Double], val cubes: Seq[Cube]) extends StratifiedCellStream[Cube, Double], DoubleFiltration[Cube]

A finite set of cubes with explicit filtration values, the cubical counterpart of ExplicitStream: for small hand-built complexes and cubical complexes that are not a full grid.

A finite set of cubes with explicit filtration values, the cubical counterpart of ExplicitStream: for small hand-built complexes and cubical complexes that are not a full grid.

Attributes

Companion
object
Experimental
true
Source
CubicalStream.scala
Supertypes
trait StratifiedCellStream[Cube, Double]
trait CellStream[Cube, Double]
trait IterableOnce[Cube]
trait Filtration[Cube, Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
open class ExplicitMetricSpace(val dist: Seq[Seq[Double]]) extends FiniteMetricSpace[Int]

Takes in an explicit distance matrix, and performs lookups in this distance matrix.

Takes in an explicit distance matrix, and performs lookups in this distance matrix.

Value parameters

dist

Distance matrix represented as a Seq[Seq[Double]]. The class expects but does not enforce:

  • dist(x1).size == dist(x2).size for all x1,x2
  • dist(x).size == dist.size for all x
  • dist(x)(x) == 0 for all x
  • dist(x)(y) == dist(y)(x) for all x,y
  • The triangle inequality Only the lower triangle is read: distance(x, y) is dist(max(x, y))(min(x, y)), as in Ripser and GUDHI, so a matrix that is not exactly symmetric gives the same results here as there.

Attributes

Experimental
true
Source
FiniteMetricSpace.scala
Supertypes
trait FiniteMetricSpace[Int]
class Object
trait Matchable
class Any
open class ExplicitStream[VertexT, FiltrationT](val filtrationValues: Map[Simplex[VertexT], FiltrationT], val simplices: Seq[Simplex[VertexT]])(using filterable: Filterable[FiltrationT])(using evidence$1: Ordering[VertexT], ordering: Ordering[FiltrationT]) extends SimplexStream[VertexT, FiltrationT], StratifiedCellStream[Simplex[VertexT], FiltrationT]

A complex given cell by cell (built by ExplicitStreamBuilder, e.g. ExplicitStreamBuilder.fromFacets(...)).

A complex given cell by cell (built by ExplicitStreamBuilder, e.g. ExplicitStreamBuilder.fromFacets(...)).

Attributes

Experimental
true
Source
SimplexStream.scala
Supertypes
trait StratifiedCellStream[Simplex[VertexT], FiltrationT]
trait SimplexStream[VertexT, FiltrationT]
trait CellStream[Simplex[VertexT], FiltrationT]
trait IterableOnce[Simplex[VertexT]]
trait Filtration[Simplex[VertexT], FiltrationT]
trait Filterable[FiltrationT]
class Object
trait Matchable
class Any
Show all
Self type
ExplicitStream[VertexT, FiltrationT]
open class ExplicitStreamBuilder[VertexT, FiltrationT](using ordering: Ordering[FiltrationT])(using evidence$1: Ordering[VertexT], filterableO: Option[Filterable[FiltrationT]] = ...) extends ReusableBuilder[(FiltrationT, Simplex[VertexT]), ExplicitStream[VertexT, FiltrationT]]

Attributes

Companion
object
Experimental
true
Source
SimplexStream.scala
Supertypes
trait ReusableBuilder[(FiltrationT, Simplex[VertexT]), ExplicitStream[VertexT, FiltrationT]]
trait Builder[(FiltrationT, Simplex[VertexT]), ExplicitStream[VertexT, FiltrationT]]
trait Growable[(FiltrationT, Simplex[VertexT])]
trait Clearable
class Object
trait Matchable
class Any
Show all
Self type
ExplicitStreamBuilder[VertexT, FiltrationT]

Attributes

Companion
class
Experimental
true
Source
SimplexStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class FastAlphaHomologyEngine[CoefficientT]

Persistent homology of a Helix alpha complex by union-find instead of matrix reduction: degree 0 on the vertices and edges, the top degree d - 1 on the dual graph of the top-dimensional simplices, as in FastCubicalHomologyEngine. In the plane those cover everything; in dimension 3 and up the degrees in between are computed by the cohomology engine on the complex without its top simplices. Works in any ambient dimension from 2, with representatives for every bar.

Persistent homology of a Helix alpha complex by union-find instead of matrix reduction: degree 0 on the vertices and edges, the top degree d - 1 on the dual graph of the top-dimensional simplices, as in FastCubicalHomologyEngine. In the plane those cover everything; in dimension 3 and up the degrees in between are computed by the cohomology engine on the complex without its top simplices. Works in any ambient dimension from 2, with representatives for every bar.

The dual graph needs every facet to have one or two top-dimensional cofaces. Unlike a grid, a triangulation does not guarantee it, so it is checked first, throwing FastAlphaTriangulationException when it fails (rare on random points). A facet's dual-edge value is its own filtration value, which can be smaller than its cofaces' circumradii (a Gabriel edge).

Attributes

Companion
object
Experimental
true
Source
FastAlphaHomology.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Experimental
true
Source
FastAlphaHomology.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class FastAlphaTriangulationException(message: String) extends RuntimeException

Thrown by FastAlphaHomologyEngine when the Helix triangulation has a facet with more than two top-dimensional cofaces, which its dual graph cannot represent. Not expected on ordinary input (Helix checks and repairs its own triangulation), and never a problem with the data: the general engines handle the same points. The message says so.

Thrown by FastAlphaHomologyEngine when the Helix triangulation has a facet with more than two top-dimensional cofaces, which its dual graph cannot represent. Not expected on ordinary input (Helix checks and repairs its own triangulation), and never a problem with the data: the general engines handle the same points. The message says so.

Attributes

Experimental
true
Source
FastAlphaHomology.scala
Supertypes
class RuntimeException
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
open class FastCubicalHomologyEngine[CoefficientT]

Persistent homology of a cubical grid by union-find instead of matrix reduction (after Le Breton, Szustakowski and Piraud, arXiv:2606.04801, extended here to any coefficient field and to representatives): degree 0 by union-find on the vertices and edges, the top degree d - 1 (d the grid's dimension) by union-find on the dual graph. In 2-D those cover everything; in dimension 3 and up the degrees in between are computed by the cohomology engine on the grid without its top cells. Requires d >= 2. A NaN (masked) pixel is not in the complex (see CubicalGridStream).

Persistent homology of a cubical grid by union-find instead of matrix reduction (after Le Breton, Szustakowski and Piraud, arXiv:2606.04801, extended here to any coefficient field and to representatives): degree 0 by union-find on the vertices and edges, the top degree d - 1 (d the grid's dimension) by union-find on the dual graph. In 2-D those cover everything; in dimension 3 and up the degrees in between are computed by the cohomology engine on the grid without its top cells. Requires d >= 2. A NaN (masked) pixel is not in the complex (see CubicalGridStream).

The dual graph: the top cells (pixels) are vertices, the codimension-1 cells (facets) edges between the one or two top cells containing them, with one extra vertex ∞, at value +Infinity, on the far side of every facet on the boundary of the grid. By Alexander duality, degree d - 1 of the sublevel filtration is degree 0 of the dual graph's superlevel filtration: union-find in decreasing value with the elder rule, each merge giving the primal bar with birth and death swapped. ∞'s component never dies. A masked pixel is in the complement from the start, as ∞ is, and so is a facet between two masked pixels or a masked pixel and the outside: a component holding one is elder to every other but ∞'s, and when it dies at a facet of value v the primal class is born at v and never dies.

Representatives: each top cell carries a sign in its dual component, kept consistent as components merge (the sign flip is solved from the merging facet's two boundary coefficients, both ±1) so that interior facets cancel; when a component dies, its representative is the boundary of its signed sum of top cells. A merge costs nearly constant time; a representative costs time proportional to its region, and only reported bars get one. Of two components born at the same value either may die, with the same bars: the smaller one does, so that a tiling's many equal maxima do not make one large region die after another.

Attributes

Experimental
true
Source
FastCubicalHomology.scala
Supertypes
class Object
trait Matchable
class Any
object Field

Attributes

Companion
trait
Experimental
true
Source
Field.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Field.type
trait Field

Attributes

Companion
object
Experimental
true
Source
Field.scala
Supertypes
class Object
trait Matchable
class Any
object Filterable

The stdlib-numeric-type instances live here, on Filterable's own companion, rather than as bare top-level package givens: found via ordinary implicit-scope search (the companion of either side of Filterable[Double]) regardless of import, rather than being ambient to every file that happens to do import streams.{given, *}.

The stdlib-numeric-type instances live here, on Filterable's own companion, rather than as bare top-level package givens: found via ordinary implicit-scope search (the companion of either side of Filterable[Double]) regardless of import, rather than being ambient to every file that happens to do import streams.{given, *}.

Attributes

Companion
trait
Experimental
true
Source
SimplexStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Filterable.type
trait Filterable[FiltrationT]

Attributes

Companion
object
Experimental
true
Source
SimplexStream.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
open class FilteredSimplexOrdering[VertexT, FiltrationT](val filtration: Filtration[Simplex[VertexT], FiltrationT])(using vertexOrdering: Ordering[VertexT])(using filtrationOrdering: Ordering[FiltrationT]) extends Ordering[Simplex[VertexT]]

Attributes

Experimental
true
Source
SimplexStream.scala
Supertypes
trait Ordering[Simplex[VertexT]]
trait PartialOrdering[Simplex[VertexT]]
trait Equiv[Simplex[VertexT]]
trait Serializable
trait Comparator[Simplex[VertexT]]
class Object
trait Matchable
class Any
Show all
trait Filtration[CellT, FiltrationT] extends Filterable[FiltrationT]

Attributes

Experimental
true
Source
SimplexStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object FiniteField

Attributes

Companion
class
Experimental
true
Source
FiniteField.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open opaque class FiniteField(val p: Int)

Attributes

Companion
object
Experimental
true
Source
FiniteField.scala
Supertypes
class Object
trait Matchable
class Any

Convenience functionality for metric spaces.

Convenience functionality for metric spaces.

Attributes

Companion
trait
Experimental
true
Source
FiniteMetricSpace.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait FiniteMetricSpace[VertexT]

Interface for being a finite metric space

Interface for being a finite metric space

Type parameters

VertexT

Type of the vertex indices for the metric space

Attributes

Companion
object
Experimental
true
Source
FiniteMetricSpace.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
open class FlagComplex(val graph: WeightedGraph, val maxDimension: Int, maxFiltrationValue: Optional[Double] = ...) extends StratifiedCellStream[Simplex[Int], Double], DoubleFiltration[Simplex[Int]]

The flag (clique) complex of a weighted graph: a set of vertices is a simplex when every two of them are joined by an edge, and it enters at the largest weight among those edges, so the filtration by weight is the Vietoris-Rips filtration of the graph read as a distance matrix with Infinity where there is no edge. Unlike VietorisRips(graph), it never forms the n x n matrix or its bit tables: cliques are grown from the sorted neighbour lists, so the cost is the number of simplices and the size of the graph, which is what makes a sparse network with a hundred thousand vertices feasible.

The flag (clique) complex of a weighted graph: a set of vertices is a simplex when every two of them are joined by an edge, and it enters at the largest weight among those edges, so the filtration by weight is the Vietoris-Rips filtration of the graph read as a distance matrix with Infinity where there is no edge. Unlike VietorisRips(graph), it never forms the n x n matrix or its bit tables: cliques are grown from the sorted neighbour lists, so the cost is the number of simplices and the size of the graph, which is what makes a sparse network with a hundred thousand vertices feasible.

val graph = WeightedGraph.unweighted(5, Seq((0, 1), (1, 2), (2, 3), (3, 4), (4, 0)))
Persistence(graph).bettiNumbers   // Vector(1, 1): the pentagon is a loop

The stream holds the simplices up to dimension maxDimension + 1, all in memory: cliques of a dense graph are many.

Value parameters

maxFiltrationValue

simplices entering later than this are left out; by default the graph's longest edge, past which nothing enters

Attributes

Experimental
true
Source
FlagComplex.scala
Supertypes
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
open class FlatCubicalGridStream(shape: IndexedSeq[Int], pixels: Array[Double], parallelFiltrationValue: Boolean = ..., nanMask: Boolean = ...) extends CubicalGridStream

A grid whose top-cell values are already one flat row-major array, as CubicalImage.fromFlatArray builds it: the engines read the array itself instead of calling topCellValue once per pixel.

A grid whose top-cell values are already one flat row-major array, as CubicalImage.fromFlatArray builds it: the engines read the array itself instead of calling topCellValue once per pixel.

Attributes

Companion
object
Experimental
true
Source
CubicalStream.scala
Supertypes
trait StratifiedCellStream[Cube, Double]
trait CellStream[Cube, Double]
trait IterableOnce[Cube]
trait Filtration[Cube, Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Experimental
true
Source
CubicalStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
trait
Experimental
true
Source
FlatLayerStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type

A stream of simplices with Int vertices and Double values that can hand over its dimensions as flat arrays, without building a Simplex for each cell. A cohomology engine (CellularCohomologyEngine) reduces such a stream straight from the arrays, and builds a Simplex only for the cells of the representatives it returns.

A stream of simplices with Int vertices and Double values that can hand over its dimensions as flat arrays, without building a Simplex for each cell. A cohomology engine (CellularCohomologyEngine) reduces such a stream straight from the arrays, and builds a Simplex only for the cells of the representatives it returns.

The coface streams behind Cech, Witness, Dowker, DtmRips and SparseRips are the implementations. To build a new filtered complex on arrays, extend RipserCofaceSimplexStream and give it a RipserCofaceSimplexStream.FlatFiltration.

Attributes

Companion
object
Experimental
true
Source
FlatLayerStream.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object GraphMetric

Distances along a weighted graph, as a metric space for the Vietoris-Rips and Cech machinery: the geodesic distance of a graph that records which points are near each other (a nearest-neighbour graph on a manifold, a network, a mesh).

Distances along a weighted graph, as a metric space for the Vietoris-Rips and Cech machinery: the geodesic distance of a graph that records which points are near each other (a nearest-neighbour graph on a manifold, a network, a mesh).

Attributes

Experimental
true
Source
GraphMetric.scala
Supertypes
class Object
trait Matchable
class Any
Self type
case class GreedyPermutation(order: IndexedSeq[Int], insertionRadius: Map[Int, Double])

A greedy (farthest-point) permutation of a whole metric space: order lists every point (order(0) the seed), and insertionRadius(p) is p's distance to the points before it (Infinity for the seed). Computed by LandmarkSelector.maxmin with as many landmarks as points.

A greedy (farthest-point) permutation of a whole metric space: order lists every point (order(0) the seed), and insertionRadius(p) is p's distance to the points before it (Infinity for the seed). Computed by LandmarkSelector.maxmin with as many landmarks as points.

Attributes

Experimental
true
Source
SheehyRipsStream.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
open class GridCellOrder(cellRank: Array[Int], weight: Array[Int]) extends Ordering[Cube]

The packed engine's order on the cubes of one grid, the generic engine's within a dimension: the rank of a cell's value, then its doubled-grid index. Every representative keeps its order, so it holds only the rank table and the strides, never the engine.

The packed engine's order on the cubes of one grid, the generic engine's within a dimension: the rank of a cell's value, then its doubled-grid index. Every representative keeps its order, so it holds only the rank table and the strides, never the engine.

Attributes

Experimental
true
Source
PackedCubicalCohomology.scala
Supertypes
trait Ordering[Cube]
trait PartialOrdering[Cube]
trait Equiv[Cube]
trait Serializable
trait Comparator[Cube]
class Object
trait Matchable
class Any
Show all
object GridCubes

Attributes

Companion
class
Experimental
true
Source
GridRanks.scala
Supertypes
class Object
trait Matchable
class Any
Self type
GridCubes.type
open class GridCubes(shape: Array[Int]) extends CellDecoder[Cube]

The cubes of one grid by their doubled-grid index, row-major with the last axis fastest: the decoder of the grid engines' packed representatives. Index order is cubeOrdering's on the grid (lexicographic on the encoding, axis 0 first). Holds only the strides and one box per coordinate value, since every representative it decodes keeps it.

The cubes of one grid by their doubled-grid index, row-major with the last axis fastest: the decoder of the grid engines' packed representatives. Index order is cubeOrdering's on the grid (lexicographic on the encoding, axis 0 first). Holds only the strides and one box per coordinate value, since every representative it decodes keeps it.

Attributes

Companion
object
Experimental
true
Source
GridRanks.scala
Supertypes
class CellDecoder[Cube]
class Object
trait Matchable
class Any
class GridRanks

The pixel (top cell) values of a cubical grid with their dense ranks: distinct holds the distinct values in ascending java.lang.Double.compare order, and rank(p) is the position of pixel p's value in it. In the T-construction every cell takes the smallest value of the pixels containing it, so every cell's value is some pixel's and its rank is the smallest rank among those pixels: the grid engines order cells by integer ranks and look the values up only to report them or compare them.

The pixel (top cell) values of a cubical grid with their dense ranks: distinct holds the distinct values in ascending java.lang.Double.compare order, and rank(p) is the position of pixel p's value in it. In the T-construction every cell takes the smallest value of the pixels containing it, so every cell's value is some pixel's and its rank is the smallest rank among those pixels: the grid engines order cells by integer ranks and look the values up only to report them or compare them.

Pixels are row-major, the last axis fastest. A NaN pixel is masked (not in the complex, see CubicalGridStream): it has no place in distinct and its rank is masked, one past every real rank. A minimum over ranks therefore skips masked pixels, and a cell's rank is masked exactly when every pixel containing it is masked.

Attributes

Companion
object
Experimental
true
Source
GridRanks.scala
Supertypes
class Object
trait Matchable
class Any
object GridRanks

Attributes

Companion
class
Experimental
true
Source
GridRanks.scala
Supertypes
class Object
trait Matchable
class Any
Self type
GridRanks.type
object Gudhi

GUDHI's OFF/nOFF point-cloud format and its .pers persistence-diagram format. For GUDHI's cubical input, which is Perseus's format, see Perseus.

GUDHI's OFF/nOFF point-cloud format and its .pers persistence-diagram format. For GUDHI's cubical input, which is Perseus's format, see Perseus.

Attributes

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

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.

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
Supertypes
class Object
trait Matchable
class Any
Self type

Harmonic representatives of the bars of the ORDINARY barcode (Basu and Cox, "Harmonic persistent homology"): each bar [s, t) gets the harmonic cycle at its birth value s, a chain that is a cycle and orthogonal to every boundary of the complex at s, picked out by the persistence module alone. A bar is a class born at s that dies at t, which is a quotient of subspaces of the harmonic chains H_p(K_s) (the classes born by s and dying by t, modulo those dying before t), and its harmonic representative is that quotient written as the orthogonal complement of the one inside the other. So the representative depends on the filtration only through its values: unlike the HarmonicChainBarcode, it does not depend on how cells of equal value are ordered.

Harmonic representatives of the bars of the ORDINARY barcode (Basu and Cox, "Harmonic persistent homology"): each bar [s, t) gets the harmonic cycle at its birth value s, a chain that is a cycle and orthogonal to every boundary of the complex at s, picked out by the persistence module alone. A bar is a class born at s that dies at t, which is a quotient of subspaces of the harmonic chains H_p(K_s) (the classes born by s and dying by t, modulo those dying before t), and its harmonic representative is that quotient written as the orthogonal complement of the one inside the other. So the representative depends on the filtration only through its values: unlike the HarmonicChainBarcode, it does not depend on how cells of equal value are ordered.

val rips = VietorisRips(points, maxDimension = 1)
val diagram = HarmonicRepresentatives(rips, maxDimension = 1)
diagram.longest.get.representative   // the harmonic cycle of the longest bar, as a chain at its birth value

The bars are those of Persistence for the same stream (in the coefficients given: reals, the default, or the exact Coefficients.Rationals; harmonic chains need an inner product, so a finite field is refused), with the representative replaced. A bar of multiplicity one has a harmonic subspace of dimension one, so its chain is unique up to a scalar: it is scaled to have 1 at its first cell in the chain order. A group of m bars with the same endpoints has an m-dimensional subspace, and its bars get an orthogonal basis of it (which basis is not canonical, the subspace is). By their Theorem 4.8, Basu and Cox show that among all cycles representing a bar the harmonic one puts the most weight on the cells essential to the bar.

The chains are computed in coordinates of the harmonic chains that the HarmonicChainBarcode run keeps alive at the values involved, with a small linear system for each bar (its size is the Betti number at the birth and the death), so the cost is that of the barcode run plus a Betti-number-sized elimination per bar.

With representatives = Representatives.Cocycles each bar gets the harmonic cocycle of its class in cohomology instead: the same construction on the dual module, whose maps go from a later value to an earlier one (the orthogonal projection of the harmonic cochains at the later value onto those at the earlier one, the adjoint of the maps of homology). The dual bar [s, t) is born at the last value before t, so its representative is the harmonic cochain at that value, a vector that is a cocycle and orthogonal to every coboundary. The cells' inner product identifies cochains with chains, so a harmonic cocycle is written in the same coordinates as a harmonic cycle, and the two differ in which value of the bar they sit at, and in the subspaces they pick out.

Attributes

Experimental
true
Source
HarmonicRepresentatives.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait HasDimension

Attributes

Experimental
true
Source
Cell.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Cell
trait OrderedCell
final class HeapChain[CellT, CoefficientT] extends Chain[CellT, CoefficientT]

A chain kept in a heap ordered so that the least cell is at the top, with arithmetic deferred: a cell can appear several times, or with a zero total, until the chain is collapsed. Its order and field are Chain's (taken as plain parameters and passed up, so that they are stored once).

A chain kept in a heap ordered so that the least cell is at the top, with arithmetic deferred: a cell can appear several times, or with a zero total, until the chain is collapsed. Its order and field are Chain's (taken as plain parameters and passed up, so that they are stored once).

Attributes

Experimental
true
Source
Chain.scala
Supertypes
class Chain[CellT, CoefficientT]
class Object
trait Matchable
class Any
object HelixDelaunay

Attributes

Companion
class
Experimental
true
Source
AlphaShapes.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class HelixDelaunay(pts: Array[Array[Double]], seed: Long = ..., requireValidTriangulation: Boolean = ...)(using factor: EpsilonFactor) extends DelaunayAlphaShapes

The Delaunay triangulation of a point cloud, built by an incremental frontier walk (https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=10917453), filtered as an alpha complex.

The Delaunay triangulation of a point cloud, built by an incremental frontier walk (https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=10917453), filtered as an alpha complex.

The walk starts from a hull facet found by gift wrapping and, across each frontier facet, takes the point whose sphere through the facet is met first: one pass over the points per facet. Points that are exactly cospherical (grids) are tiled as a cluster. Every result is checked cheaply (each point a vertex, no facet in three top simplices, every boundary facet on the convex hull); a result that fails is re-triangulated from slightly perturbed points, with every radius recomputed from the original coordinates. The perturbation (1e-4 of the point spacing) decides how exact ties are broken, and can also flip a near-tie closer than that. The same pts and seed always give the same triangulation.

Limitation: a very small Epsilon (far below the default 1e-5) can leave an exactly degenerate input (a 3-D grid) with an invalid triangulation when the perturbed retriangulation does not converge.

Value parameters

pts

the points to triangulate

requireValidTriangulation

off by default. When on, the triangulation is also checked for cavities (a homology computation), and a result that cannot be repaired raises an exception instead of being returned as it is.

seed

seeds the perturbation used when a triangulation has to be repaired; general-position input does not depend on it.

Attributes

Companion
object
Experimental
true
Source
AlphaShapes.scala
Supertypes
class AlphaShapes
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
object HopcroftKarp

Maximum-cardinality bipartite matching (Hopcroft-Karp). Used by BarcodeDistance.bottleneckDistance as the feasibility check inside a binary search over candidate distances: "does a perfect matching exist using only edges of cost <= threshold".

Maximum-cardinality bipartite matching (Hopcroft-Karp). Used by BarcodeDistance.bottleneckDistance as the feasibility check inside a binary search over candidate distances: "does a perfect matching exist using only edges of cost <= threshold".

Attributes

Experimental
true
Source
BipartiteMatching.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object Hungarian

Minimum-cost perfect matching on a square matrix of finite costs (the Hungarian algorithm, O(n³), by shortest augmenting paths with potentials), for BarcodeDistance.wassersteinDistance.

Minimum-cost perfect matching on a square matrix of finite costs (the Hungarian algorithm, O(n³), by shortest augmenting paths with potentials), for BarcodeDistance.wassersteinDistance.

Attributes

Experimental
true
Source
BipartiteMatching.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Hungarian.type
object Hyperplane

Attributes

Companion
class
Experimental
true
Source
AlphaShapes.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Hyperplane.type
case class Hyperplane(normal: Point, offset: Double)

The hyperplane { x : normal . x = offset }; its "light" side is where normal . x >= offset.

The hyperplane { x : normal . x = offset }; its "light" side is where normal . x >= offset.

Attributes

Companion
object
Experimental
true
Source
AlphaShapes.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class Hypersphere(center: Point, radius: Double)(using epsilon: Epsilon)

Attributes

Companion
object
Experimental
true
Source
AlphaShapes.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Hypersphere

Attributes

Companion
class
Experimental
true
Source
AlphaShapes.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object Image

Attributes

Companion
class
Experimental
true
Source
Persistence.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Image.type
final case class Image(values: IndexedSeq[Double], shape: IndexedSeq[Int], sublevel: Boolean = ..., nanMask: Boolean = ...)

A grayscale image (or voxel grid) for Persistence(Image(...)): values in row-major order, shape its size per axis. Sublevel filtration by default (dark regions first); sublevel = false for superlevel. A pixel of value Double.NaN is masked (missing data): it is not in the complex, in either direction (NaN has no sign). Infinite values are ordinary values: Double.PositiveInfinity enters after every finite value of a sublevel image and before them in a superlevel one, Double.NegativeInfinity the reverse. nanMask = false turns masks off, for data where a NaN can only be a bug: a NaN pixel is then an error, naming the pixel.

A grayscale image (or voxel grid) for Persistence(Image(...)): values in row-major order, shape its size per axis. Sublevel filtration by default (dark regions first); sublevel = false for superlevel. A pixel of value Double.NaN is masked (missing data): it is not in the complex, in either direction (NaN has no sign). Infinite values are ordinary values: Double.PositiveInfinity enters after every finite value of a sublevel image and before them in a superlevel one, Double.NegativeInfinity the reverse. nanMask = false turns masks off, for data where a NaN can only be a bug: a NaN pixel is then an error, naming the pixel.

Attributes

Companion
object
Experimental
true
Source
Persistence.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
open class IncrementalVietorisRipsSimplexStream(metricSpace: FiniteMetricSpace[Int], val maxDimension: Int, maxFiltrationValue: Option[Double] = ..., keepCriterion: PartialFunction[Simplex[Int], Boolean] = ..., useLargestNeighborBound: Boolean = ...) extends EnumeratingCofaceSimplexStream

A reference Vietoris-Rips construction following Rieser's New-VR algorithm ("A New Construction of the Vietoris-Rips Complex", arXiv:2301.07191v3, Algorithms 1-4), kept close to the paper as a baseline for the faster constructions. Built eagerly, layer by layer (layer k + 1 from layer k and its candidate lists), the breadth-first reading of the paper's recursion, so any dimension can be served in any order.

A reference Vietoris-Rips construction following Rieser's New-VR algorithm ("A New Construction of the Vietoris-Rips Complex", arXiv:2301.07191v3, Algorithms 1-4), kept close to the paper as a baseline for the faster constructions. Built eagerly, layer by layer (layer k + 1 from layer k and its candidate lists), the breadth-first reading of the paper's recursion, so any dimension can be served in any order.

maxFiltrationValue (default Infinity) defines the graph whose clique complex is built: {i, j} is an edge iff distance(i, j) &lt;= maxFiltrationValue. The largestNeighbor table (L in Algorithm 2) only shortens scans. Every simplex is reached exactly once, so nothing needs deduplicating. Unlike Algorithm 4, which always includes the edges, maxDimension is the top simplex dimension served, so maxDimension = 0 gives the vertices only.

Attributes

Experimental
true
Source
SimplexStream.scala
Supertypes
trait CofaceSimplexStream[Int, Double]
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
open class IntMetricSpace[VertexT](val metricSpace: FiniteMetricSpace[VertexT]) extends FiniteMetricSpace[Int]

Wrapper class to make any metricspace into a metricspace defined on indices 0 through metricSpace.size. This way, code can assume that the index set is contiguous.

Wrapper class to make any metricspace into a metricspace defined on indices 0 through metricSpace.size. This way, code can assume that the index set is contiguous.

Type parameters

VertexT

Type of the vertex indices for the wrapped metric space

Value parameters

metricSpace

Wrapped metric space

Attributes

Experimental
true
Source
FiniteMetricSpace.scala
Supertypes
trait FiniteMetricSpace[Int]
class Object
trait Matchable
class Any
object Involution

Cycle representatives from a persistence pairing, by involuted persistent homology (Čufar and Virk, "Fast computation of persistent homology representatives with involuted persistent homology", arXiv:2105.03629).

Cycle representatives from a persistence pairing, by involuted persistent homology (Čufar and Virk, "Fast computation of persistent homology representatives with involuted persistent homology", arXiv:2105.03629).

Given the pairing a cohomology engine found, only the boundary columns of death cells are reduced: a column that reduces to zero never supplies a pivot, so leaving those out changes no reduced column. For a finite bar (σ, τ) the cycle is R_τ, the reduced boundary of τ: its youngest cell is σ, and it is the boundary of a chain whose youngest cell is τ. For an essential bar it is the cycle σ - Σ c V_τ' that the reduction of ∂σ to zero produces.

The pairing must come from the same total order as youngestFirst; every pivot is checked against the paired birth cell, and a mismatch throws.

Attributes

Experimental
true
Source
Involution.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Involution.type
open class Kruskal[T](elements: Seq[T], distance: (T, T) => Double, maxDistance: Double = ...)(using orderingT: Ordering[T])

This implementation of Kruskal's algorithm will return two iterators of vertex pairs: the first iterator is a Minimal Spanning Tree in increasing weight order, while the second iterator gives all the non-included

This implementation of Kruskal's algorithm will return two iterators of vertex pairs: the first iterator is a Minimal Spanning Tree in increasing weight order, while the second iterator gives all the non-included

Attributes

Companion
object
Experimental
true
Source
UnionFind.scala
Supertypes
class Object
trait Matchable
class Any
object Kruskal

Attributes

Companion
class
Experimental
true
Source
UnionFind.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Kruskal.type
abstract class Lab(characteristic: Int, precision: Double = ...)

What every lab shares: a coefficient field chosen by its characteristic (0 for Double compared within precision, a prime p for Z/p), with CoefficientT, Fp(...) and the field's given; flat re-exports of the whole library and the sset add-on, so import lab.{*, given} is the only import a lab user needs; and cats' .show syntax. Concrete labs add the conveniences of their setting: TDAlab (simplicial), CubicalLab. Engines never consult a lab: it is for writing chain algebra by hand.

What every lab shares: a coefficient field chosen by its characteristic (0 for Double compared within precision, a prime p for Z/p), with CoefficientT, Fp(...) and the field's given; flat re-exports of the whole library and the sset add-on, so import lab.{*, given} is the only import a lab user needs; and cats' .show syntax. Concrete labs add the conveniences of their setting: TDAlab (simplicial), CubicalLab. Engines never consult a lab: it is for writing chain algebra by hand.

Attributes

Experimental
true
Source
package.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class CubicalLab
object F17
object F2
object F3
object Reals
class TDAlab
object F17
object F2
object F3
object Reals
Show all
case class LandmarkSelection(landmarks: IndexedSeq[Int], coveringRadius: Double, insertionRadius: Map[Int, Double] = ...)

landmarks(i) is the ambient index of the i-th landmark -- the mapping every witness-stream class below needs to translate its own LOCAL 0 until landmarks.size simplex vertex indices back to the caller's original point cloud (matlab.TDA4j does this for cycleVertices). coveringRadius is R = max_x min_l d(x,l). insertionRadius maps an ambient index to its own greedy-permutation lambda (see maxmin's doc); empty for random (no meaningful lambda) and for a hand-built selection not routed through maxmin.

landmarks(i) is the ambient index of the i-th landmark -- the mapping every witness-stream class below needs to translate its own LOCAL 0 until landmarks.size simplex vertex indices back to the caller's original point cloud (matlab.TDA4j does this for cycleVertices). coveringRadius is R = max_x min_l d(x,l). insertionRadius maps an ambient index to its own greedy-permutation lambda (see maxmin's doc); empty for random (no meaningful lambda) and for a hand-built selection not routed through maxmin.

Attributes

Experimental
true
Source
WitnessStream.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Choosing the landmarks of a witness complex (de Silva and Carlsson, "Topological estimation using witness complexes", 2004), as JavaPlex does: landmarks are a subset of the points, given by their numbers. Assumes the metric space's elements are 0 until size.

Choosing the landmarks of a witness complex (de Silva and Carlsson, "Topological estimation using witness complexes", 2004), as JavaPlex does: landmarks are a subset of the points, given by their numbers. Assumes the metric space's elements are 0 until size.

Attributes

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

Lenstra-Lenstra-Lovász lattice basis reduction of a Gram matrix (Scoccola, Gakhar, Bush, Schonsheck, Rask, Zhou, Perea, "Toroidal Coordinates: Decorrelating Circular Coordinates With Lattice Reduction", arXiv:2212.07201, Algorithm 4). Given the Gram matrix G of k independent vectors, factor G = C Cᵀ (Cholesky), run LLL on the rows of C, and return the unimodular integer change of basis: the shortest, most nearly orthogonal basis of the same lattice. CircularCoordinates.computeToroidal uses it to choose among the equally valid bases of a group of H¹ classes.

Lenstra-Lenstra-Lovász lattice basis reduction of a Gram matrix (Scoccola, Gakhar, Bush, Schonsheck, Rask, Zhou, Perea, "Toroidal Coordinates: Decorrelating Circular Coordinates With Lattice Reduction", arXiv:2212.07201, Algorithm 4). Given the Gram matrix G of k independent vectors, factor G = C Cᵀ (Cholesky), run LLL on the rows of C, and return the unimodular integer change of basis: the shortest, most nearly orthogonal basis of the same lattice. CircularCoordinates.computeToroidal uses it to choose among the equally valid bases of a group of H¹ classes.

The Gram-Schmidt step projects onto the orthogonalized vectors, as in the textbook algorithm. DREiMac's _gram_schmidt projects onto the original ones, which agrees for k = 2 but not for k >= 3, so results can differ from DREiMac's there.

Attributes

Experimental
true
Source
LatticeReduction.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class LayeredInorderSimplexStream(metricSpace: FiniteMetricSpace[Int], maxFiltrationValue: Option[Double] = ..., val candidates: Candidates = ...) extends EnumeratingCofaceSimplexStream

Vietoris-Rips, each dimension generated from the one below already in filtration order, so nothing above the edges is sorted (Bauer, Matuszewski and Vejdemo-Johansson, "Generating cofaces in Vietoris-Rips filtration order", arXiv:2411.05495, Theorem 3 and Proposition 7).

Vietoris-Rips, each dimension generated from the one below already in filtration order, so nothing above the edges is sorted (Bauer, Matuszewski and Vejdemo-Johansson, "Generating cofaces in Vietoris-Rips filtration order", arXiv:2411.05495, Theorem 3 and Proposition 7).

A simplex of diameter α is generated by exactly one of its facets, which has the same diameter, so walking dimension d in filtration order and emitting each simplex's same-diameter cofacets walks dimension d + 1 in filtration order. Each simplex carries its first longest edge, which its cofacets inherit unchanged and which decides the vertices it may add. Ties are listed colexicographically descending, as EnumeratingCofaceSimplexStream lists them: same cells, values and order. maxFiltrationValue defaults to the minimum enclosing radius.

Every dimension built so far is kept, as primitive arrays (LayeredInorderSimplexStream.Layer).

Attributes

Companion
object
Experimental
true
Source
LayeredInorderSimplexStream.scala
Supertypes
trait CofaceSimplexStream[Int, Double]
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Experimental
true
Source
LayeredInorderSimplexStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class LazyWitnessSimplexStream(ambientMetricSpace: FiniteMetricSpace[Int], val landmarks: IndexedSeq[Int], nu: Int = ..., keepCriterion: PartialFunction[Simplex[Int], Boolean] = ..., maxFiltrationValue: Option[Double] = ..., parallelFiltrationValue: Boolean = ...) extends RipserCofaceSimplexStream

The lazy witness complex (JavaPlex's LazyWitnessStream): the flag complex of WitnessMetricSpace. Its maxFiltrationValue defaults to the minimum enclosing radius of that metric space, which is a valid cutoff for any flag complex. Vertices are landmark numbers.

The lazy witness complex (JavaPlex's LazyWitnessStream): the flag complex of WitnessMetricSpace. Its maxFiltrationValue defaults to the minimum enclosing radius of that metric space, which is a valid cutoff for any flag complex. Vertices are landmark numbers.

Attributes

Experimental
true
Source
WitnessStream.scala
Supertypes
trait CofaceSimplexStream[Int, Double]
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
trait LevelwiseSimplexStream[VertexT, FiltrationT] extends StratifiedCellStream[Simplex[VertexT], FiltrationT]

Attributes

Experimental
true
Source
SimplexStream.scala
Supertypes
trait StratifiedCellStream[Simplex[VertexT], FiltrationT]
trait CellStream[Simplex[VertexT], FiltrationT]
trait IterableOnce[Simplex[VertexT]]
trait Filtration[Simplex[VertexT], FiltrationT]
trait Filterable[FiltrationT]
class Object
trait Matchable
class Any
Show all
Known subtypes
open class LimitedAlphaShapesStream(helix: DelaunayAlphaShapes, maxDim: Int) extends LevelwiseSimplexStream[Int, Double], DoubleFiltration[Simplex[Int]]

helix without its simplices of dimension greater than maxDim: what the fast alpha engine hands the chunks engine for the degrees between 0 and the top. Filtration values and order are those of helix.

helix without its simplices of dimension greater than maxDim: what the fast alpha engine hands the chunks engine for the degrees between 0 and the top. Filtration values and order are those of helix.

Attributes

Experimental
true
Source
AlphaShapes.scala
Supertypes
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
open class LimitedCofaceSimplexStream(stream: CofaceSimplexStream[Int, Double], maxDim: Int) extends CofaceSimplexStream[Int, Double], FlatLayerStream, DoubleFiltration[Simplex[Int]]

stream with simplices up to dimension maxDim (a simplex dimension; Truncated.ofCofaces takes the homological degree instead).

stream with simplices up to dimension maxDim (a simplex dimension; Truncated.ofCofaces takes the homological degree instead).

Attributes

Experimental
true
Source
SimplexStream.scala
Supertypes
trait CofaceSimplexStream[Int, Double]
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
open class LimitedCubicalGridStream(stream: CubicalGridStream, maxDim: Int) extends StratifiedCellStream[Cube, Double], DoubleFiltration[Cube]

stream without its cells of dimension above maxDim, with the same values and order.

stream without its cells of dimension above maxDim, with the same values and order.

Attributes

Experimental
true
Source
CubicalStream.scala
Supertypes
trait StratifiedCellStream[Cube, Double]
trait CellStream[Cube, Double]
trait IterableOnce[Cube]
trait Filtration[Cube, Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
object LinearAlgebra

Small dense linear algebra over any Field: row reduction, rank and null space. Meant for the SMALL matrices that come up when asking structural questions about a hand-sized complex (the rank of a map on homology, ...); the persistence engines have their own sparse reduction and do not use this.

Small dense linear algebra over any Field: row reduction, rank and null space. Meant for the SMALL matrices that come up when asking structural questions about a hand-sized complex (the rank of a map on homology, ...); the persistence engines have their own sparse reduction and do not use this.

Attributes

Experimental
true
Source
LinearAlgebra.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object LowerStar

The lower-star filtration of a function on the vertices of a simplicial complex: a simplex enters when its last vertex does, so its value is the largest of its vertices' values. It computes the sublevel-set persistence of the function (a height function on a mesh, a measurement at each node of a network, a scalar field sampled at the vertices of a triangulation).

The lower-star filtration of a function on the vertices of a simplicial complex: a simplex enters when its last vertex does, so its value is the largest of its vertices' values. It computes the sublevel-set persistence of the function (a height function on a mesh, a measurement at each node of a network, a scalar field sampled at the vertices of a triangulation).

val stream = LowerStar(Seq(Simplex(0, 1, 2), Simplex(2, 3)), v => heights(v))
Persistence(stream)

Attributes

Experimental
true
Source
LowerStar.scala
Supertypes
class Object
trait Matchable
class Any
Self type
LowerStar.type
object MapAlgebra

Image, kernel and cokernel of a map of persistence modules that are sums of interval modules, over any field.

Image, kernel and cokernel of a map of persistence modules that are sums of interval modules, over any field.

The source has bars [b_i, d_i) and the target [b'_j, d'_j); the map is a matrix with a coefficient for each pair of a source bar i and a target bar j, given column by column (columns(i) maps j to the coefficient). A coefficient can be nonzero only where there is a map of interval modules at all, b'_j &lt;= b_i &lt; d'_j &lt;= d_i (isLegal): the generator of bar i, born at b_i, goes to the component of the target alive then, and the source dies no sooner than the component does.

Each result is a list of bars as (bar index, interval); the interval is [birth, death) in the numbers of the input. The three are computed by one kind of reduction, with the elder rule:

  • the image is the submodule of the target generated by the images of the source generators, each born at its bar's birth; reducing the generators in order of birth, with the target components ordered by death, a generator that does not reduce to zero is a bar from its birth to the death of its leading component;
  • the cokernel is the target modulo the image; its generators are the target bars, and the relations are the images of the source generators at their births and each target bar's own death. Taking relations in order of time, with the generators ordered by birth, a relation that does not reduce to zero kills the youngest generator in it at its time;
  • the kernel is the cokernel of the dual map, in the reversed order of the filtration (a bar [b, d) becomes [-d, -b)).

The tests check all three against the ranks of the structure maps of the modules, computed by linear algebra.

Attributes

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

Attributes

Companion
class
Experimental
true
Source
MinimumEnclosingBall.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class MinimumEnclosingBall(val center: Array[Double], val squaredRadius: Double)

A closed ball in R^d: center and squaredRadius. MinimumEnclosingBall.apply computes the smallest one containing a finite set of points.

A closed ball in R^d: center and squaredRadius. MinimumEnclosingBall.apply computes the smallest one containing a finite set of points.

Value parameters

center

the centre, one coordinate per dimension

squaredRadius

the squared radius, at least the squared distance from center to every point it was computed for

Attributes

Companion
object
Experimental
true
Source
MinimumEnclosingBall.scala
Supertypes
class Object
trait Matchable
class Any
object MorseCell

Attributes

Companion
class
Experimental
true
Source
MorseCell.scala
Supertypes
class Object
trait Matchable
class Any
Self type
MorseCell.type
final case class MorseCell[CellT](cell: CellT)(complex: MorseComplex[CellT])

A critical cell of a discrete Morse complex (MorseComplex): the cell of the complex it comes from, with the Morse boundary, the sum over the gradient paths from its boundary to critical cells. A stream of these (morse.stream) has the persistent homology of the stream it comes from; cell is the cell of that stream, and morse.lift takes a chain of these back to a chain of cells of it.

A critical cell of a discrete Morse complex (MorseComplex): the cell of the complex it comes from, with the Morse boundary, the sum over the gradient paths from its boundary to critical cells. A stream of these (morse.stream) has the persistent homology of the stream it comes from; cell is the cell of that stream, and morse.lift takes a chain of these back to a chain of cells of it.

Two Morse cells are equal when their cells are: the complex is how the cell finds its boundary, not part of its identity.

Attributes

Companion
object
Experimental
true
Source
MorseCell.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final class MorseComplex[CellT]

A discrete Morse complex of a filtered complex: an acyclic matching of cells into pairs (a, b) with a a face of b of one dimension less and both entering at the same filtration value, the cells left over (the critical cells) and the Morse boundary between them. Its persistent homology is that of the filtered complex it comes from, and it has fewer cells, often far fewer: Persistence(morse.stream) computes the barcode on the critical cells, and morse.lift takes a representative back to the original complex. Build it with DiscreteMorse.

A discrete Morse complex of a filtered complex: an acyclic matching of cells into pairs (a, b) with a a face of b of one dimension less and both entering at the same filtration value, the cells left over (the critical cells) and the Morse boundary between them. Its persistent homology is that of the filtered complex it comes from, and it has fewer cells, often far fewer: Persistence(morse.stream) computes the barcode on the critical cells, and morse.lift takes a representative back to the original complex. Build it with DiscreteMorse.

The Morse boundary of a critical cell τ is found by flowing its boundary down the gradient: a face a that is the lower member of a pair (a, b) is replaced by the other faces of b (subtracting ∂b times the coefficient of a over the incidence of a in b), until only critical cells, and cells matched with a face below them, remain, and the latter are dropped. It is computed in the coefficients asked for, so a pair needs an incidence of +1 or -1, which is a unit in every field.

Attributes

Experimental
true
Source
DiscreteMorse.scala
Supertypes
class Object
trait Matchable
class Any
case class NegativeInfinity[FiltrationT]()(using evidence$1: Ordering[FiltrationT]) extends BarcodeEndpoint[FiltrationT]

Attributes

Experimental
true
Source
Barcode.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait BarcodeEndpoint[FiltrationT]
class Object
trait Matchable
class Any
Show all
open class NeighbourLists(val offsets: Array[Int], val targets: Array[Int], val distances: Array[Double])

Each vertex's neighbours within a threshold, ascending, with their distances, in compressed rows: vertex v's are targets(offsets(v) until offsets(v + 1)). Built by NeighbourLists.within.

Each vertex's neighbours within a threshold, ascending, with their distances, in compressed rows: vertex v's are targets(offsets(v) until offsets(v + 1)). Built by NeighbourLists.within.

Attributes

Companion
object
Experimental
true
Source
SimplexIndexing.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Experimental
true
Source
SimplexIndexing.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class NoIntegerCocycleException(message: String) extends RuntimeException

The chosen cocycle has no integer lift at the chosen prime: either the class is torsion (as on RP²) and has no circle-valued coordinate at all, or prime is too small for the integer cocycle's entries; in the second case a larger prime helps.

The chosen cocycle has no integer lift at the chosen prime: either the class is torsion (as on RP²) and has no circle-valued coordinate at all, or prime is too small for the integer cocycle's entries; in the second case a larger prime helps.

Attributes

Experimental
true
Source
CircularCoordinates.scala
Supertypes
class RuntimeException
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
case class OpenEndpoint[FiltrationT](value: FiltrationT)(using evidence$1: Ordering[FiltrationT]) extends BarcodeEndpoint[FiltrationT]

Attributes

Experimental
true
Source
Barcode.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait BarcodeEndpoint[FiltrationT]
class Object
trait Matchable
class Any
Show all
final case class Optional[+A](toOption: Option[A])

An optional parameter that a call site can give as a plain value: maxFiltrationValue = 2.0 (or 2), as well as Some(2.0), None or any Option[Double]. The conversions apply only at parameters of type Optional[...], with no import at the call site.

An optional parameter that a call site can give as a plain value: maxFiltrationValue = 2.0 (or 2), as well as Some(2.0), None or any Option[Double]. The conversions apply only at parameters of type Optional[...], with no import at the call site.

Attributes

Companion
object
Experimental
true
Source
Optional.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Optional

Attributes

Companion
class
Experimental
true
Source
Optional.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Optional.type
trait OrderedBasis[CellT, CoefficientT]

A formal sum with a leading term (its first cell under CellT's order, and that cell's coefficient), which pivot reduction needs. Chain is the instance.

A formal sum with a leading term (its first cell under CellT's order, and that cell's coefficient), which pivot reduction needs. Chain is the instance.

Attributes

Experimental
true
Source
Cell.scala
Supertypes
class Object
trait Matchable
class Any
trait OrderedCell extends Cell

Attributes

Companion
object
Experimental
true
Source
Cell.scala
Supertypes
trait Cell
trait HasDimension
class Object
trait Matchable
class Any
object OrderedCell

Attributes

Companion
trait
Experimental
true
Source
Cell.scala
Supertypes
class Object
trait Matchable
class Any
Self type
final class PackedChain[CellT, CoefficientT](val keys: Array[Int], val coefficients: Array[AnyRef], val decoder: CellDecoder[CellT])(order: Ordering[CellT], field: is[CoefficientT, Field]) extends Chain[CellT, CoefficientT]

A chain stored packed, as the grid engines store representatives: keys(i) is a cell's key, which decoder turns into the cell, and coefficients(i) its coefficient. The keys are distinct and their cells ascending under the chain's order; every coefficient is nonzero. Nothing else is stored: reading the chain decodes its cells afresh (nothing is cached, so reading it does not make it bigger), and arithmetic on it gives a heap chain. The decoder and the order are kept by every chain they serve, so they must hold only what they need, never an engine.

A chain stored packed, as the grid engines store representatives: keys(i) is a cell's key, which decoder turns into the cell, and coefficients(i) its coefficient. The keys are distinct and their cells ascending under the chain's order; every coefficient is nonzero. Nothing else is stored: reading the chain decodes its cells afresh (nothing is cached, so reading it does not make it bigger), and arithmetic on it gives a heap chain. The decoder and the order are kept by every chain they serve, so they must hold only what they need, never an engine.

Attributes

Experimental
true
Source
Chain.scala
Supertypes
class Chain[CellT, CoefficientT]
class Object
trait Matchable
class Any
open class PackedCubicalCohomologyEngine[C](grid: CubicalGridStream, topDim: Int, ranks: GridRanks, useApparentPairs: Boolean = ..., useUnionFind: Boolean = ...)(using evidence$1: Field { type Self = C; })

Persistent cohomology of a cubical grid by Bauer's Ripser algorithm on the grid itself: what CellularCohomologyEngine computes on a CubicalGridStream, or on its cells up to dimension topDim as a LimitedCubicalGridStream shows them -- the same bars, pairs, cocycles and cycles, term for term and in the same list order -- without a Cube, a hash of one or a Chain inside the reduction.

Persistent cohomology of a cubical grid by Bauer's Ripser algorithm on the grid itself: what CellularCohomologyEngine computes on a CubicalGridStream, or on its cells up to dimension topDim as a LimitedCubicalGridStream shows them -- the same bars, pairs, cocycles and cycles, term for term and in the same list order -- without a Cube, a hash of one or a Chain inside the reduction.

A cell is its index in the doubled grid (KMM encoding, see Cube). Within a dimension cells are ordered by the rank of their value (GridRanks) and then by index: the generic engine's order there, value ascending, then the encoding ascending. Boundaries and coboundaries come from index arithmetic. Clearing as in the generic engine; apparent pairs (a cell whose oldest same-value cofacet has it as its youngest same-value facet) are paired without a reduction and their columns rebuilt when another column needs them, which changes no output (useApparentPairs = false turns them off). Degree 0 is paired by union-find over the edges, the elder rule, with the indicator of the dying component as the cocycle (useUnionFind = false reduces the vertices' coboundaries instead, with the same output). Cycles come from the involution on the same pairs, specialised to packed cells as PackedRipserCohomologyEngine does it. A cell every pixel around which is masked (NaN) is not in the complex: it has rank GridRanks.masked, and is never listed nor met as a cofacet.

Attributes

Companion
object
Experimental
true
Source
PackedCubicalCohomology.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Experimental
true
Source
PackedCubicalCohomology.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class PackedRipserCohomologyEngine[CoefficientT](metricSpace: FiniteMetricSpace[Int], maxDimension: Int, useApparentPairs: Boolean = ..., maxFiltrationValue: Option[Double] = ..., neighbourLists: Option[Boolean] = ..., wideIndices: Option[Boolean] = ..., useEmergentPairs: Boolean = ..., useUnionFind: Boolean = ...)(using evidence$1: Field { type Self = CoefficientT; })

Persistent cohomology of the Vietoris-Rips complex of a metric space by Bauer's Ripser algorithm (arXiv:1908.02518): the fast engine for Vietoris-Rips, and the MATLAB/CLI default there. Cells are packed as (diameter, combinatorial index) pairs (DiameterIndex, Ripser's diameter_index_t); clearing, apparent pairs, emergent pairs and the enclosing-radius cutoff as in Ripser.

Persistent cohomology of the Vietoris-Rips complex of a metric space by Bauer's Ripser algorithm (arXiv:1908.02518): the fast engine for Vietoris-Rips, and the MATLAB/CLI default there. Cells are packed as (diameter, combinatorial index) pairs (DiameterIndex, Ripser's diameter_index_t); clearing, apparent pairs, emergent pairs and the enclosing-radius cutoff as in Ripser.

Reports degrees 0 .. maxDimension, each bar with its representative cocycle over DiameterIndex cells: decode a cell of a degree-k bar with vertices(cell, k + 1). maxFiltrationValue defaults to the minimum enclosing radius, past which nothing new is born. useApparentPairs = false, useEmergentPairs = false and useUnionFind = false turn off the apparent-pair shortcut, the emergent-pair shortcut and the pairing of degree 0 by union-find over the edges (the elder rule, as Ripser does it), which change no output (for benchmarking). An emergent pair is a column whose oldest cofacet of the same diameter is the pivot of no earlier column: it is paired with that cofacet without being reduced, and kept only as the simplex that makes it (rebuilt if a later column needs it), which saves the memory of its stored column.

Under a threshold that keeps few of the pairs (a large point cloud with a small maxFiltrationValue), cofacets are found from each vertex's list of neighbours within the threshold instead of by trying every vertex, as Ripser does with a sparse distance matrix. The lists are built when at most a quarter of all pairs are within the threshold (neighbourLists = Some(true) or Some(false) decides it instead); the output is the same either way.

The combinatorial index of a simplex is one Long while the indices of every simplex up to dimension maxDimension + 1 fit in one, and two words (WideSimplexIndexing, up to 126 bits) beyond: for 16,000 points to degree 3, or 122,000 to degree 2. The choice is made before the run (wideIndices decides it instead) and changes no output.

Attributes

Experimental
true
Source
PackedRipserCohomology.scala
Supertypes
class Object
trait Matchable
class Any

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.

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
Supertypes
class Object
trait Matchable
class Any
Self type
object Perseus

Perseus's cubical toplex (dense grid) input format and its persistence-interval output format, as read by GUDHI.

Perseus's cubical toplex (dense grid) input format and its persistence-interval output format, as read by GUDHI.

Perseus lists the first axis fastest, the opposite of CubicalImage.fromFlatArray; the readers and writers convert. A value of -1 (a missing cube) is read as NaN: masked, not in the complex, in either direction. Periodic boundaries (negative sizes, a GUDHI extension) are refused.

Perseus's simplicial toplex formats (simtop and nmfsimtop, as described in Perseus's manual) are read and written as lists of facets with birth times; toplexStream makes the filtered complex of such a list.

Attributes

Experimental
true
Source
Perseus.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Perseus.type
object Persistence

Attributes

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

Utility functions for working with persistence bars.

Utility functions for working with persistence bars.

For any cases not covered by these simplistic factory method, the programmer gets to instantiate their own PersistenceBar object.

Attributes

Companion
class
Experimental
true
Source
Barcode.scala
Supertypes
class Object
trait Matchable
class Any
Self type
case class PersistenceBar[FiltrationT, AnnotationT](dim: Int, lower: BarcodeEndpoint[FiltrationT], upper: BarcodeEndpoint[FiltrationT], annotation: Option[AnnotationT] = ..., cells: Option[Pair[_]] = ...)(using evidence$1: Ordering[FiltrationT])

One bar of a barcode: a degree dim, a lower and an upper endpoint, and optionally an annotation -- in every engine's output, the bar's representative chain.

One bar of a barcode: a degree dim, a lower and an upper endpoint, and optionally an annotation -- in every engine's output, the bar's representative chain.

A finished bar is [birth, death); a class still alive at the end of the filtration is [birth, ∞); a class alive at the value a diagram was truncated at, f, is [birth, f] (closed: it exists at f).

Type parameters

AnnotationT

Type of the annotation (we would expect this to be Chain).

FiltrationT

Type of the filtration parameter

Value parameters

cells

the cell that opens the bar and the one that closes it, when the engine records them (PersistenceBar.birthCell, PersistenceBar.deathCell read them typed). Not part of equality.

Attributes

Companion
object
Experimental
true
Source
Barcode.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
trait
Experimental
true
Source
PersistenceDiagram.scala
Supertypes
class Object
trait Matchable
class Any
Self type
trait PersistenceDiagram[CellT]

A finished persistence computation as a plain, immutable value: the bars with their representative chains, plus what is needed to read them at a smaller parameter. What Persistence(...) returns, and what HomologyState.snapshotAt(f) takes from a cursor.

A finished persistence computation as a plain, immutable value: the bars with their representative chains, plus what is needed to read them at a smaller parameter. What Persistence(...) returns, and what HomologyState.snapshotAt(f) takes from a cursor.

The coefficient field is chosen at runtime (characteristic = 17, ...), so its type is the member Coefficient; import diagram.given brings the field into scope for arithmetic on representatives.

Attributes

Companion
object
Experimental
true
Source
PersistenceDiagram.scala
Supertypes
class Object
trait Matchable
class Any
trait PersistenceEngine[CellT, C]

"Run to the end and give me the barcode", for the engines that take a stream and work for any cell type: naive (CellularHomologyEngine), chunks (CellularPersistenceInChunksEngine) and cohomology (CellularCohomologyEngine). The engines themselves offer more (a cursor, queries at intermediate values); this is the common denominator, used where the engine is chosen at runtime.

"Run to the end and give me the barcode", for the engines that take a stream and work for any cell type: naive (CellularHomologyEngine), chunks (CellularPersistenceInChunksEngine) and cohomology (CellularCohomologyEngine). The engines themselves offer more (a cursor, queries at intermediate values); this is the common denominator, used where the engine is chosen at runtime.

The Ripser engines are not instances: they take a metric space rather than a stream.

For naive and cohomology the stream decides the top degree: to get degrees 0 .. k, hand them a stream with cells up to dimension k + 1 (what VietorisRips(points, maxDimension = k) is). A stream that says it was cut off (homologyDegreeLimit) gets no bars above that degree from either; a complete complex is read whole. chunks(maxDim) takes the degree itself.

Attributes

Companion
object
Experimental
true
Source
PersistenceEngine.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Experimental
true
Source
PersistenceEngine.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Dropping short bars, relative to the scale of the input: the policy behind diagram.longerThanFraction(), bars.longerThanFraction() and the MATLAB/CLI default. (Zero-length bars are already gone: engines leave them out unless asked. For a fixed threshold, longerThan(eps) is simpler.)

Dropping short bars, relative to the scale of the input: the policy behind diagram.longerThanFraction(), bars.longerThanFraction() and the MATLAB/CLI default. (Zero-length bars are already gone: engines leave them out unless asked. For a fixed threshold, longerThan(eps) is simpler.)

This is a rule of thumb for what to show, not a statistical test: it keeps a bar because it is long compared with the data's scale, not because it is unlikely to be noise. For a threshold that comes from the sample itself, see BootstrapBand.

'''The scale.''' A bar is judged against a scale the caller supplies: for a point cloud or distance matrix, metricSpace.minimumEnclosingRadius (Ripser's enclosing radius: past it the Vietoris-Rips complex is a cone and nothing new is born, so every bar lies in [0, scale]; it is also the default Vietoris-Rips truncation); for a cubical image, the range of its values. It is used in the units the complex reports (diameters for Vietoris-Rips, radii for Cech/alpha). Without such a quantity, filtrationRange, the span of the barcode's own finite endpoints, is the fallback.

'''The rule.''' A bar is kept iff it is essential or its persistence is strictly greater than the threshold. A threshold &lt;= 0 keeps everything.

Attributes

Experimental
true
Source
PersistenceFilter.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class PersistenceInChunksEngine[VertexT, CoefficientT](maxDim: Int = ...)(using evidence$1: Ordering[VertexT], evidence$2: Field { type Self = CoefficientT; }) extends CellularPersistenceInChunksEngine[Simplex[VertexT], CoefficientT]

The chunks engine (CellularPersistenceInChunksEngine) on simplices with vertices of type VertexT.

The chunks engine (CellularPersistenceInChunksEngine) on simplices with vertices of type VertexT.

Attributes

Companion
object
Experimental
true
Source
Homology.scala
Supertypes
class CellularPersistenceInChunksEngine[Simplex[VertexT], CoefficientT]
class Object
trait Matchable
class Any

Attributes

Companion
class
Experimental
true
Source
Homology.scala
Supertypes
class Object
trait Matchable
class Any
Self type
class PersistenceMap[S, T, C]

The map on persistent homology that a map of filtered complexes induces, and its image, kernel and cokernel as barcodes: what survives from the smaller space in the larger, what dies on the way in, and what only the larger one sees.

The map on persistent homology that a map of filtered complexes induces, and its image, kernel and cokernel as barcodes: what survives from the smaller space in the larger, what dies on the way in, and what only the larger one sees.

val sub = Persistence(points.take(30), maxDimension = 2, includeZeroLength = true)
val whole = Persistence(points, maxDimension = 2, includeZeroLength = true)
val inclusion = PersistenceMap.inclusion(sub, whole)
inclusion.image(1)      // the loops of the subsample, as far as they stay loops in the whole
inclusion.cokernel(1)   // the loops that only the whole sample has

For each degree the matrix has a row for each bar of the target and a column for each bar of the source: column i is the pushforward of the source bar's representative cycle, written in the target's bars at the time the source bar is born. The bars are those of the diagrams without the zero-length ones (a class that never exists), and sourceBars and targetBars give them in the order the matrix uses.

The map must send each cell to a chain of cells that have already entered the target by the time the cell enters the source (it preserves the filtration). Both diagrams need representative cycles and the cells of their bars (the default of Persistence); the target must keep its zero-length bars, includeZeroLength = true, because their representatives are part of what the reduction reads. They must be over the same field: the same characteristic (or the same coefficients).

Attributes

See also

MapAlgebra for the image, kernel and cokernel of a map of barcodes that you write down yourself

Companion
object
Experimental
true
Source
PersistenceMap.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Experimental
true
Source
PersistenceMap.scala
Supertypes
class Object
trait Matchable
class Any
Self type

The persistent Laplacian of a filtered complex (Wang, Nguyen and Wei; Mémoli, Wan and Wang): a symmetric positive semidefinite matrix Δ_k^{s,t} on the k-cells of the complex at s, for every pair s H_k(K_t), and whose other eigenvalues carry geometric information the barcode does not (the smallest nonzero one is a persistent spectral gap).

The persistent Laplacian of a filtered complex (Wang, Nguyen and Wei; Mémoli, Wan and Wang): a symmetric positive semidefinite matrix Δ_k^{s,t} on the k-cells of the complex at s, for every pair s H_k(K_t), and whose other eigenvalues carry geometric information the barcode does not (the smallest nonzero one is a persistent spectral gap).

val rips = VietorisRips(points, maxDimension = 1)
val laplacian = PersistentLaplacian(rips, dimension = 1, from = 0.4, to = 0.9)
laplacian.bettiNumber     // loops at 0.4 that are still loops at 0.9
laplacian.spectralGap     // the smallest nonzero eigenvalue
laplacian.eigenvalues     // ascending

With C^{s,t}_{k+1} the chains of K_t whose boundary lies in K_s, the persistent Laplacian is ∂ ∂^* + ∂_k^{s *} ∂_k^s, the first term being the boundary of C^{s,t}_{k+1} into the k-chains of K_s composed with its adjoint, in the inner product in which the cells are orthonormal. Written with the matrices of K_t and its rows split into those in K_s (D) and those in K_t \ K_s (R), that is D (1 - R^+ R) D^T + A^T A, A being the boundary of the k-cells of K_s; at s = t it is the Hodge Laplacian. The coefficients are real numbers, the matrices dense: for complexes of a few thousand cells in the dimension asked for. The stream has to hold the cells of dimension dimension + 1 (a stream cut off at homological degree k does, up to k).

Attributes

Experimental
true
Source
PersistentLaplacian.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object Phat

PHAT's boundary-matrix formats, with the conventions of phat/boundary_matrix.h (load_ascii, save_ascii, load_binary, save_binary): a matrix over Z/2 whose columns are numbered from 0, each with a dimension and the sorted row indices of its nonzero entries.

PHAT's boundary-matrix formats, with the conventions of phat/boundary_matrix.h (load_ascii, save_ascii, load_binary, save_binary): a matrix over Z/2 whose columns are numbered from 0, each with a dimension and the sorted row indices of its nonzero entries.

  • ASCII: one column per line, the dimension first and then the row indices, separated by whitespace; empty lines and lines starting with # are skipped.
  • Binary: an Int64 column count, then for each column its dimension (Int64), its number of entries N (Int64) and the N row indices (Int64). PHAT writes the machine's byte order; this reader and writer use little-endian, which is the byte order of x86 and ARM machines.

PHAT reads a matrix whose columns are in filtration order, so a face's row comes before the column of its coface: fromStream builds that matrix from a stream, sorting its cells by the stream's filtrationOrdering.

Attributes

Experimental
true
Source
Phat.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Phat.type
final case class PointCloud(points: Array[Array[Double]])

A finite point cloud in Euclidean space, one row per point. Every entry point that takes points takes a PointCloud, and Array[Array[Double]], Seq[Seq[Double]] and Seq[Array[Double]] all convert to one where a PointCloud is expected (into), so callers never need to care which collection their points are in.

A finite point cloud in Euclidean space, one row per point. Every entry point that takes points takes a PointCloud, and Array[Array[Double]], Seq[Seq[Double]] and Seq[Array[Double]] all convert to one where a PointCloud is expected (into), so callers never need to care which collection their points are in.

Attributes

Companion
object
Experimental
true
Source
PointCloud.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object PointCloud

Attributes

Companion
class
Experimental
true
Source
PointCloud.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
PointCloud.type

A complex built from a point cloud alone -- implemented by the dispatcher objects VietorisRips, Cech and AlphaShapes, so they double as the choice in Persistence(points, complex = Cech). (Complexes that need more input than points -- witness landmarks, a Dowker relation -- are built directly and passed to Persistence as a stream.)

A complex built from a point cloud alone -- implemented by the dispatcher objects VietorisRips, Cech and AlphaShapes, so they double as the choice in Persistence(points, complex = Cech). (Complexes that need more input than points -- witness landmarks, a Dowker relation -- are built directly and passed to Persistence as a stream.)

Attributes

Experimental
true
Source
PointCloud.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object AlphaShapes
object Cech
object VietorisRips
case class PositiveInfinity[FiltrationT]()(using evidence$1: Ordering[FiltrationT]) extends BarcodeEndpoint[FiltrationT]

Attributes

Experimental
true
Source
Barcode.scala
Supertypes
trait Serializable
trait Product
trait Equals
trait BarcodeEndpoint[FiltrationT]
class Object
trait Matchable
class Any
Show all
object PowerDistance

Attributes

Companion
trait
Experimental
true
Source
AlphaComplexDQP.scala
Supertypes
class Object
trait Matchable
class Any
Self type

The data the algorithm needs: a finite set of sites with power weights.

The data the algorithm needs: a finite set of sites with power weights.

Everything in the QP is expressible through squared distances alone, because

B_ij = (x_i - x)·(x_j - x) = ( d²(i,x) + d²(j,x) - d²(i,j) ) / 2 U_i = ( p(i) - p(x) - d²(i,x) ) / 2

so the solver never sees coordinates. Coordinates are optional and used only to materialise the witness map Phi (Definition 11).

Caveat: the QP is convex only if B is positive semidefinite, i.e. only if the squared distances come from a Euclidean embedding. Feeding in a non-Euclidean metric (as Vietoris-Rips happily allows) is not supported; the notion of "alpha complex" is not defined there either.

Attributes

Companion
object
Experimental
true
Source
AlphaComplexDQP.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object ProductCell

Attributes

Companion
class
Experimental
true
Source
ProductCell.scala
Supertypes
class Object
trait Matchable
class Any
Self type
final case class ProductCell[A, B](left: A, right: B)(context: Context[A, B])

A cell left × right of the product of two cell complexes, of dimension dim(left) + dim(right), with the boundary ∂(a × b) = ∂a × b + (-1)^dim(a) a × ∂b (so ∂∂ = 0 over any field). Chains over these cells are the tensor product of the chain complexes; build the cells of a filtered product with ProductComplex.

A cell left × right of the product of two cell complexes, of dimension dim(left) + dim(right), with the boundary ∂(a × b) = ∂a × b + (-1)^dim(a) a × ∂b (so ∂∂ = 0 over any field). Chains over these cells are the tensor product of the chain complexes; build the cells of a filtered product with ProductComplex.

Two product cells are equal when their factors are: the context is how the cell knows the structure of its factors, not part of its identity.

Attributes

Companion
object
Experimental
true
Source
ProductCell.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

The product of two filtered complexes as a stream: a cell σ × τ for every pair of a cell of each, entering at the larger of the two values (Combine.Max, the default: the sublevel set at t is the product of the two sublevel sets) or at their sum (Combine.Sum: the tensor product of the two filtered chain complexes).

The product of two filtered complexes as a stream: a cell σ × τ for every pair of a cell of each, entering at the larger of the two values (Combine.Max, the default: the sublevel set at t is the product of the two sublevel sets) or at their sum (Combine.Sum: the tensor product of the two filtered chain complexes).

val circle = VietorisRips(points, maxDimension = 2)
val interval = VietorisRips(otherPoints, maxDimension = 2)
Persistence(ProductComplex(circle, interval))        // the homology of the product, by any engine
Barcode.kunneth(bars1, bars2)                         // the same bars from the bars of the factors

Both streams are held in memory, and the product has a cell for every pair, so this is for factors of a few hundred cells each. A factor cut off at a homological degree k (homologyDegreeLimit) makes the product accurate to the smaller of the two degrees. The bars carry chains of ProductCells, (left, right) being the cells of the factors.

Attributes

Experimental
true
Source
ProductComplex.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class RadiusLimitedAlphaShapes(full: AlphaShapes, maxRadius: Double) extends AlphaShapes, FlatLayerStream

The simplices of full with alpha value at most maxRadius, in full's order and with its values. Alpha values do not decrease from a face to a coface, so this is a subcomplex.

The simplices of full with alpha value at most maxRadius, in full's order and with its values. Alpha values do not decrease from a face to a coface, so this is a subcomplex.

Attributes

Experimental
true
Source
AlphaShapes.scala
Supertypes
class AlphaShapes
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
open class RecursiveStackSimplexEnumerator(val metricSpace: FiniteMetricSpace[Int], val targetDimension: Int = ...)(val query: SpatialQuery[Int] = ...) extends Iterator[Simplex[Int]]

Attributes

Experimental
true
Source
VietorisRips.scala
Supertypes
trait Iterator[Simplex[Int]]
trait IterableOnceOps[Simplex[Int], Iterator, Iterator[Simplex[Int]]]
trait IterableOnce[Simplex[Int]]
class Object
trait Matchable
class Any
Show all
open class RecursiveStackVietorisRipsSimplexStream(val metricSpace: FiniteMetricSpace[Int]) extends LevelwiseSimplexStream[Int, Double], DoubleFiltration[Simplex[Int]]

A third, independent Vietoris-Rips coface-enumeration strategy, built on a recursive stack and spatial (VP-tree) neighbor query rather than SimplexIndexing's combinatorial-number-system enumeration. A cross-validation baseline for the canonical VR streams, not a speed-competitive production engine in its own right.

A third, independent Vietoris-Rips coface-enumeration strategy, built on a recursive stack and spatial (VP-tree) neighbor query rather than SimplexIndexing's combinatorial-number-system enumeration. A cross-validation baseline for the canonical VR streams, not a speed-competitive production engine in its own right.

Attributes

Experimental
true
Source
VietorisRips.scala
Supertypes
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
object Relative

The pair (X, A) as a stream: the cells of X that are not in the subcomplex A, with boundaries that leave out the faces in A, so that its persistent homology is the relative one, H(X_t, A_t) with A_t = A ∩ X_t.

The pair (X, A) as a stream: the cells of X that are not in the subcomplex A, with boundaries that leave out the faces in A, so that its persistent homology is the relative one, H(X_t, A_t) with A_t = A ∩ X_t.

val rips = VietorisRips(points, maxDimension = 2)
Persistence(Relative.ofVertices(rips, Set(0, 1, 2)))   // the pairs of the Rips complex modulo the one on 0, 1, 2

The subcomplex has to be closed under faces (a face of a cell in A is in A), and each of its cells enters X no later than it would as a cell of X on its own; neither is checked. The bars carry chains of RelativeCells, the cell of X being cell. For a connected complex whose vertices all enter together, relative to one vertex, that is the reduced homology: the bar of the whole complex in degree 0 is gone and the rest stays.

Attributes

Experimental
true
Source
Relative.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Relative.type
final case class RelativeCell[CellT](cell: CellT)(context: Context[CellT])

A cell of the quotient complex of a pair (X, A): a cell of X that is not in the subcomplex A, with a boundary that leaves out the faces in A. Chains over these cells are the relative chains C(X) / C(A), so the persistent homology of a stream of them is that of the pair. cell is the cell of X; build them with Relative.

A cell of the quotient complex of a pair (X, A): a cell of X that is not in the subcomplex A, with a boundary that leaves out the faces in A. Chains over these cells are the relative chains C(X) / C(A), so the persistent homology of a stream of them is that of the pair. cell is the cell of X; build them with Relative.

Two relative cells are equal when their cells are: the context is how the cell knows A, not part of its identity.

Attributes

Companion
object
Experimental
true
Source
RelativeCell.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object RelativeCell

Attributes

Companion
class
Experimental
true
Source
RelativeCell.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Which representative Persistence gives each bar: a '''cycle''' (a chain without boundary, born at the bar's start and a boundary at its end; for a loop, a path of edges around it) or a '''cocycle''' (a cochain whose coboundary is zero; for a loop, a set of edges cutting across it, what circular coordinates are built from).

Which representative Persistence gives each bar: a '''cycle''' (a chain without boundary, born at the bar's start and a boundary at its end; for a loop, a path of edges around it) or a '''cocycle''' (a cochain whose coboundary is zero; for a loop, a set of edges cutting across it, what circular coordinates are built from).

Attributes

Experimental
true
Source
Persistence.scala
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait RingModule

Specifies what it means for the type Self to be a module (or vector space) over the [Numeric] (ie ring-like) type R.

Specifies what it means for the type Self to be a module (or vector space) over the [Numeric] (ie ring-like) type R.

A minimal implementation of this trait will define zero, plus, scalarMultiply, and at least one of minus and negate

Type parameters

R

Type of the ring coefficients

Self

Type of the module elements.

Attributes

Experimental
true
Source
RingModule.scala
Supertypes
class Object
trait Matchable
class Any
object Ripser

Ripser's input formats (point-cloud, lower-distance, upper-distance, distance, binary, sparse), with the conventions of ripser.cpp. Not supported: dipha (use Dipha).

Ripser's input formats (point-cloud, lower-distance, upper-distance, distance, binary, sparse), with the conventions of ripser.cpp. Not supported: dipha (use Dipha).

Attributes

Experimental
true
Source
Ripser.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Ripser.type
open class RipserCofaceSimplexStream(metricSpace: FiniteMetricSpace[Int], keepCriterion: PartialFunction[Simplex[Int], Boolean] = ..., maxFiltrationValue: Option[Double] = ..., filtrationValueOverride: Option[PartialFunction[Simplex[Int], Double]] = ..., parallelFiltrationValue: Boolean = ...) extends EnumeratingCofaceSimplexStream, FlatLayerStream

Vietoris-Rips, or any filtration monotone along faces given as filtrationValueOverride, built dimension by dimension from the cofaces of the simplices kept in the dimension below (the loop Cech, Witness, Dowker, DtmRips and SparseRips reuse). keepCriterion and maxFiltrationValue decide what is kept; the criterion must be closed under faces (see CofaceSimplexStream.keepCriterion). It is asked about each candidate that has a kept facet, whether the stream builds its dimensions with the coface loop or with flatGenerator, which cuts each dimension to what the criterion keeps before generating the next from it.

Vietoris-Rips, or any filtration monotone along faces given as filtrationValueOverride, built dimension by dimension from the cofaces of the simplices kept in the dimension below (the loop Cech, Witness, Dowker, DtmRips and SparseRips reuse). keepCriterion and maxFiltrationValue decide what is kept; the criterion must be closed under faces (see CofaceSimplexStream.keepCriterion). It is asked about each candidate that has a kept facet, whether the stream builds its dimensions with the coface loop or with flatGenerator, which cuts each dimension to what the criterion keeps before generating the next from it.

Attributes

Companion
object
Experimental
true
Source
SimplexStream.scala
Supertypes
trait CofaceSimplexStream[Int, Double]
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
Known subtypes

Attributes

Companion
class
Experimental
true
Source
SimplexStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class RipserCohomologyEngine[CoefficientT](metricSpace: FiniteMetricSpace[Int], maxDimension: Int, useApparentPairs: Boolean = ..., maxFiltrationValue: Option[Double] = ..., memoizeFiltrationValue: Boolean = ...)(using evidence$1: Field { type Self = CoefficientT; })

Persistent cohomology of the Vietoris-Rips complex of a metric space by Bauer's Ripser algorithm (arXiv:1908.02518), on materialized Simplex[Int] cells indexed by the combinatorial number system (SimplexIndexing). A reference implementation: PackedRipserCohomologyEngine runs the same algorithm on packed cells and is the one to use; this one exists to cross-check it.

Persistent cohomology of the Vietoris-Rips complex of a metric space by Bauer's Ripser algorithm (arXiv:1908.02518), on materialized Simplex[Int] cells indexed by the combinatorial number system (SimplexIndexing). A reference implementation: PackedRipserCohomologyEngine runs the same algorithm on packed cells and is the one to use; this one exists to cross-check it.

Reports degrees 0 .. maxDimension, each bar with its representative cocycle. Uses clearing (required for correctness here, not only speed) and skips the reduction of apparent pairs (Definition 3.2), which changes no output; useApparentPairs = false turns that off for benchmarking.

maxFiltrationValue defaults to the minimum enclosing radius, past which the complex is a cone and nothing new is born, so the barcode is the same as untruncated. memoizeFiltrationValue caches every diameter it computes (faster, more memory); off by default.

Attributes

Experimental
true
Source
RipserCohomology.scala
Supertypes
class Object
trait Matchable
class Any
open class SheehyRipsSimplexStream(val ambientMetricSpace: FiniteMetricSpace[Int], val permutation: GreedyPermutation, val epsilon: Double, keepCriterion: PartialFunction[Simplex[Int], Boolean] = ..., maxFiltrationValue: Option[Double] = ..., parallelFiltrationValue: Boolean = ...) extends RipserCofaceSimplexStream

The sparse Vietoris-Rips filtration of Cavanna, Jahanseir and Sheehy, "A Geometric Perspective on Sparse Filtrations" (arXiv:1506.03797, CCCG 2015): the greedy-permutation form of Sheehy's linear-size approximation ("Linear-Size Approximations to the Vietoris-Rips Filtration", DCG 2013, arXiv:1203.6786). Its barcode is a (1 + epsilon)-multiplicative approximation of the Vietoris-Rips barcode (Theorem 5), from a complex of size linear in the number of points for data of bounded doubling dimension. (Sheehy 2013's epsilon is a different parameter: its factor is 1/(1 - 2 epsilon).) The edges are computed from all pairs, O(n^2), rather than by the paper's O(n log n) neighbour search: the complex to reduce is small, its construction is not.

The sparse Vietoris-Rips filtration of Cavanna, Jahanseir and Sheehy, "A Geometric Perspective on Sparse Filtrations" (arXiv:1506.03797, CCCG 2015): the greedy-permutation form of Sheehy's linear-size approximation ("Linear-Size Approximations to the Vietoris-Rips Filtration", DCG 2013, arXiv:1203.6786). Its barcode is a (1 + epsilon)-multiplicative approximation of the Vietoris-Rips barcode (Theorem 5), from a complex of size linear in the number of points for data of bounded doubling dimension. (Sheehy 2013's epsilon is a different parameter: its factor is 1/(1 - 2 epsilon).) The edges are computed from all pairs, O(n^2), rather than by the paper's O(n log n) neighbour search: the complex to reduce is small, its construction is not.

==The construction==

Given a greedy permutation with insertion radii lambda_p (Infinity for the first point) and epsilon in (0, 1):

  • the ball of p at scale alpha has radius min(alpha, lambda_p (1 + epsilon) / epsilon);
  • it is empty from alpha > lambda_p (1 + epsilon)^2 / epsilon on (vanish(p)): no new simplex uses p after that, though nothing already present is removed (the filtration is the running union of the nerves);
  • an edge {p, q} is born at the smallest alpha at which the two balls meet (Algorithm 3, edgeBirth);
  • a simplex is born at the latest birth of its edges, if that is at most the earliest vanish of its vertices (Section 5.3), and never otherwise.

Algorithm 3 computes an edge's birth without the vanish check that Section 5.3 requires of every simplex (for epsilon = 1, lambda_p = 1, lambda_q = 10, d = 10 it gives 8, while p vanishes at 4); edgeBirth applies the check to edges too.

Units: the paper's alpha is a radius; every value here is doubled, so that values are diameters like every other Vietoris-Rips filtration (an unsparsified edge gets exactly its length).

maxFiltrationValue is always clamped to maxFiniteFiltrationValue, the largest finite edge birth: the enclosing radius is no bound here, and an unclamped Infinity threshold would admit simplices that should never appear.

The value of a simplex is not its diameter, so the Ripser engines do not apply; the naive, chunks and cohomology engines do.

Attributes

Companion
object
Experimental
true
Source
SheehyRipsStream.scala
Supertypes
trait CofaceSimplexStream[Int, Double]
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Experimental
true
Source
SheehyRipsStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class SignedUnionFind[C](size: Int)(using fr: is[C, Field])

Union-find over 0 until size in which every element carries an orientation, a unit of the field C, relative to the root of its component. It is the bookkeeping behind the representatives of the dual union-find engines (FastCubicalHomologyEngine, FastAlphaHomologyEngine): an element is a top cell, a component a region of top cells, and the region's coherently oriented sum is sum of orientation(c) * c over its members.

Union-find over 0 until size in which every element carries an orientation, a unit of the field C, relative to the root of its component. It is the bookkeeping behind the representatives of the dual union-find engines (FastCubicalHomologyEngine, FastAlphaHomologyEngine): an element is a top cell, a component a region of top cells, and the region's coherently oriented sum is sum of orientation(c) * c over its members.

  • find compresses paths and composes orientations along them, so orientation(i) is amortised near-constant.
  • union(young, old, flip) hangs root young under root old, multiplying the whole young component's orientations by flip (a unit, ±1 in practice). It never touches the members.
  • The merges also form a forest that path compression does not change: members(root) walks the subtree of a root, which is frozen once that root has been merged away, and returns every member with its orientation relative to that root.

A merge therefore costs nearly constant time, and a representative costs time proportional to its region, paid only for the bars that are reported.

Attributes

Experimental
true
Source
SignedUnionFind.scala
Supertypes
class Object
trait Matchable
class Any

Constructors and operations of Simplex: Simplex(1, 2, 3) (also spelled ∆(1, 2, 3)), Simplex.from(seq), and the extension methods of SimplexOps (dim, +, union, toList, ...), found without an import.

Constructors and operations of Simplex: Simplex(1, 2, 3) (also spelled ∆(1, 2, 3)), Simplex.from(seq), and the extension methods of SimplexOps (dim, +, union, toList, ...), found without an import.

Attributes

Experimental
true
Source
Simplex.scala
Supertypes
trait SimplexOps
class Object
trait Matchable
class Any
Self type
Simplex.type
object SimplexEdge

Attributes

Companion
class
Experimental
true
Source
VietorisRips.scala
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class SimplexEdge(simplex: Simplex[Int], edge: Simplex[Int], diameter: Double)

Attributes

Companion
object
Experimental
true
Source
VietorisRips.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Experimental
true
Source
SimplexIndexing.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class SimplexIndexing(val vertexCount: Int)

Attributes

Companion
object
Experimental
true
Source
SimplexIndexing.scala
Supertypes
class Object
trait Matchable
class Any

Simplex's default instances, mixed into object Simplex so they sit in the type's IMPLICIT scope: found with no import at all, and consulted only when no given is lexically visible -- a stream's or a user's own Simplex[V] is OrderedCell/Ordering[Simplex[V]] always wins, never ties. Lives here (not in Simplex.scala) for the same opaque-transparency reason as simplexIsOrderedCell.

Simplex's default instances, mixed into object Simplex so they sit in the type's IMPLICIT scope: found with no import at all, and consulted only when no given is lexically visible -- a stream's or a user's own Simplex[V] is OrderedCell/Ordering[Simplex[V]] always wins, never ties. Lives here (not in Simplex.scala) for the same opaque-transparency reason as simplexIsOrderedCell.

Attributes

Experimental
true
Source
SimplexOrderedCell.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Simplex
trait SimplexOps

The operations on a Simplex: a selection of SortedSet's methods, and simplex-specific ones. Mixed into object Simplex, so they are found without an import.

The operations on a Simplex: a selection of SortedSet's methods, and simplex-specific ones. Mixed into object Simplex, so they are found without an import.

Attributes

Experimental
true
Source
SimplexOps.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Simplex
trait SimplexStream[VertexT, FiltrationT] extends CellStream[Simplex[VertexT], FiltrationT]

Abstract trait for representing a sequence of simplices.

Abstract trait for representing a sequence of simplices.

Type parameters

FiltrationT

Type of the filtration values.

VertexT

Type of vertices of the contained simplices.

Attributes

Todo

We may want to change this to inherit instead from IterableOnce[Simplex[VertexT]], so that a lazy computed simplex stream can be created and fit in the type hierarchy.

Companion
object
Experimental
true
Source
SimplexStream.scala
Supertypes
trait CellStream[Simplex[VertexT], FiltrationT]
trait IterableOnce[Simplex[VertexT]]
trait Filtration[Simplex[VertexT], FiltrationT]
trait Filterable[FiltrationT]
class Object
trait Matchable
class Any
Show all
Known subtypes
class ExplicitStream[VertexT, FiltrationT]
object SimplexStream

Attributes

Companion
trait
Experimental
true
Source
SimplexStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
class
Experimental
true
Source
Homology.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class SimplicialHomologyEngine[VertexT, CoefficientT, FiltrationT]()(using evidence$1: Ordering[VertexT], evidence$2: Field { type Self = CoefficientT; }, evidence$3: Ordering[FiltrationT]) extends CellularHomologyEngine[Simplex[VertexT], CoefficientT, FiltrationT]

The naive engine (CellularHomologyEngine) on simplices with vertices of type VertexT.

The naive engine (CellularHomologyEngine) on simplices with vertices of type VertexT.

Attributes

Companion
object
Experimental
true
Source
Homology.scala
Supertypes
class CellularHomologyEngine[Simplex[VertexT], CoefficientT, FiltrationT]
class Object
trait Matchable
class Any
object SortIndices

A stable merge sort of the indices 0 until n by a strict "comes before" relation on indices, without boxing: the fast engines order millions of cells by values and keys held in primitive arrays.

A stable merge sort of the indices 0 until n by a strict "comes before" relation on indices, without boxing: the fast engines order millions of cells by values and keys held in primitive arrays.

Attributes

Experimental
true
Source
SortIndices.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class SparseMetricSpace[VertexT](metricSpace: FiniteMetricSpace[VertexT], diameter: Double)(using evidence$1: Ordering[VertexT]) extends FiniteMetricSpace[VertexT]

****** Sparse Metric Spaces and the Dory storage *******

****** Sparse Metric Spaces and the Dory storage *******

Attributes

Experimental
true
Source
FiniteMetricSpace.scala
Supertypes
trait FiniteMetricSpace[VertexT]
class Object
trait Matchable
class Any
object SparseRips

Sheehy's sparse (approximate) Rips complex, Cavanna-Jahanseir-Sheehy 2015; epsilon strictly in (0, 1).

Sheehy's sparse (approximate) Rips complex, Cavanna-Jahanseir-Sheehy 2015; epsilon strictly in (0, 1).

Attributes

Experimental
true
Source
Complexes.scala
Supertypes
class Object
trait Matchable
class Any
Self type
SparseRips.type
trait SpatialQuery[VertexT]

******* Efficient Spatial Queries *******

******* Efficient Spatial Queries *******

Attributes

Experimental
true
Source
FiniteMetricSpace.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class BruteForce[VertexT]
class VantagePointQuery[VertexT]
trait StratifiedCellStream[CellT, FiltrationT] extends CellStream[CellT, FiltrationT]

Attributes

Experimental
true
Source
SimplexStream.scala
Supertypes
trait CellStream[CellT, FiltrationT]
trait IterableOnce[CellT]
trait Filtration[CellT, FiltrationT]
trait Filterable[FiltrationT]
class Object
trait Matchable
class Any
Show all
Known subtypes
open class TDAlab(characteristic: Int, precision: Double = ...) extends Lab

The simplicial lab: import TDAlab.F17.{*, given} (or val lab = TDAlab(p); import lab.{*, given} for another prime) brings in everything Lab does, plus chain arithmetic (⊠, +, -) on Chain[Simplex[Int], CoefficientT] and an implicit Simplex -> Chain widening, so chains can be written straight up and down: Fp(2) ⊠ ∆(1, 2) - ∆(2, 3).

The simplicial lab: import TDAlab.F17.{*, given} (or val lab = TDAlab(p); import lab.{*, given} for another prime) brings in everything Lab does, plus chain arithmetic (⊠, +, -) on Chain[Simplex[Int], CoefficientT] and an implicit Simplex -> Chain widening, so chains can be written straight up and down: Fp(2) ⊠ ∆(1, 2) - ∆(2, 3).

Attributes

Companion
object
Experimental
true
Source
package.scala
Supertypes
class Lab
class Object
trait Matchable
class Any
Known subtypes
object F17
object F2
object F3
object Reals
object TDAlab

Prebuilt simplicial labs: import TDAlab.F17.{*, given}. F17 is the library default (FiniteField.DefaultPrime).

Prebuilt simplicial labs: import TDAlab.F17.{*, given}. F17 is the library default (FiniteField.DefaultPrime).

Attributes

Companion
class
Experimental
true
Source
package.scala
Supertypes
class Object
trait Matchable
class Any
Self type
TDAlab.type

Sliding-window (Takens delay) embedding of a time series into a point cloud: the point at time t is the window (x_t, x_{t+delay}, ..., x_{t+(dimension-1) delay}). A periodic signal traces a closed curve in the window space, so Persistence(TakensEmbedding(signal, dimension = 2, delay = quarterPeriod)) shows the period as a long bar of degree 1; a quasi-periodic one traces a torus.

Sliding-window (Takens delay) embedding of a time series into a point cloud: the point at time t is the window (x_t, x_{t+delay}, ..., x_{t+(dimension-1) delay}). A periodic signal traces a closed curve in the window space, so Persistence(TakensEmbedding(signal, dimension = 2, delay = quarterPeriod)) shows the period as a long bar of degree 1; a quasi-periodic one traces a torus.

The dimension and delay decide what the embedding shows: too small a delay flattens the curve onto a line, too large a one folds it. delayByAutocorrelation gives a first guess for the delay.

Attributes

Experimental
true
Source
TakensEmbedding.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object ToMATo

ToMATo, Topological Mode Analysis Tool (Chazal, Guibas, Oudot, Skraba, "Persistence-based clustering in Riemannian manifolds", J. ACM 60, 2013): clustering by the peaks of a density, where a peak counts only if it is persistent.

ToMATo, Topological Mode Analysis Tool (Chazal, Guibas, Oudot, Skraba, "Persistence-based clustering in Riemannian manifolds", J. ACM 60, 2013): clustering by the peaks of a density, where a peak counts only if it is persistent.

Take a function f (a density estimate: large at the centre of a cluster) on the vertices of a graph (which vertices are neighbours). Walk through the vertices from the highest value down. A vertex with no higher neighbour is a '''peak''' and starts a cluster; any other vertex joins the cluster of its highest neighbour, and if it also touches another cluster, the two merge when the lower of their peaks is less than tau above the vertex, that is, when the valley between them is shallower than tau. So tau is a depth: peaks that rise more than tau above every pass that joins them stay separate clusters.

The depths of all the valleys are the finite bars of the degree-0 persistent homology of f on the graph, which diagram returns; choose tau in a gap of that diagram, between the depths of the peaks you want and the depths of the noise (Plot.barcode(ToMATo.diagram(...)) shows it).

Bars are in the library's sublevel convention for a superlevel filtration: a peak of height h is born at -h, so a bar's persistence is the depth of its valley.

Attributes

Experimental
true
Source
ToMATo.scala
Supertypes
class Object
trait Matchable
class Any
Self type
ToMATo.type
open class TopCofacetEnumerator(val simplex: SimplexEdge, val neighbors: SortedSet[Int])(using val metricSpace: FiniteMetricSpace[Int])

Attributes

Experimental
true
Source
VietorisRips.scala
Supertypes
class Object
trait Matchable
class Any
object Truncated

A complex truncated at a homological degree. Like every complex entry point (VietorisRips, Cech, Witness, Dowker, DtmRips, SparseRips), maxDimension is the top homological degree: the stream holds one dimension more, so an engine run on it also reports classes of degree maxDimension + 1, which are incomplete (the Persistence verb drops them).

A complex truncated at a homological degree. Like every complex entry point (VietorisRips, Cech, Witness, Dowker, DtmRips, SparseRips), maxDimension is the top homological degree: the stream holds one dimension more, so an engine run on it also reports classes of degree maxDimension + 1, which are incomplete (the Persistence verb drops them).

Attributes

Experimental
true
Source
Complexes.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Truncated.type
open class TruncatedSimplexStream(stream: LevelwiseSimplexStream[Int, Double], maxSimplexDimension: Int) extends LevelwiseSimplexStream[Int, Double], FlatLayerStream, DoubleFiltration[Simplex[Int]]

A stratified simplex stream cut off above simplex dimension maxSimplexDimension; filtration order and values are the wrapped stream's own. (Use Truncated, whose argument is a homological degree.)

A stratified simplex stream cut off above simplex dimension maxSimplexDimension; filtration order and values are the wrapped stream's own. (Use Truncated, whose argument is a homological degree.)

Attributes

Experimental
true
Source
Complexes.scala
Supertypes
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
open class UnionFind[T](vertices: IterableOnce[T])

Attributes

Experimental
true
Source
UnionFind.scala
Supertypes
class Object
trait Matchable
class Any
open class UnitSignedUnionFind(size: Int)

SignedUnionFind with every orientation a sign ±1, kept in bytes: exact whenever every flip is ±1, as in the cubical dual, where a flip is a product of boundary coefficients ±1. The field never enters; the caller maps a sign to its field once, when it writes a representative. Integers map to any field by a ring homomorphism, so this gives the same coefficients as the field arithmetic, and none of its boxing.

SignedUnionFind with every orientation a sign ±1, kept in bytes: exact whenever every flip is ±1, as in the cubical dual, where a flip is a product of boundary coefficients ±1. The field never enters; the caller maps a sign to its field once, when it writes a representative. Integers map to any field by a ring homomorphism, so this gives the same coefficients as the field arithmetic, and none of its boxing.

Attributes

Experimental
true
Source
SignedUnionFind.scala
Supertypes
class Object
trait Matchable
class Any
open class VantagePointQuery[VertexT](metricSpace: FiniteMetricSpace[VertexT]) extends SpatialQuery[VertexT]

Neighbour search by a VantagePointTree over the points of metricSpace. Fast on a genuine metric space; see VantagePointTree for the tie-break of nearestNeighbors (earlier in metricSpace.elements first).

Neighbour search by a VantagePointTree over the points of metricSpace. Fast on a genuine metric space; see VantagePointTree for the tie-break of nearestNeighbors (earlier in metricSpace.elements first).

Attributes

Experimental
true
Source
FiniteMetricSpace.scala
Supertypes
trait SpatialQuery[VertexT]
class Object
trait Matchable
class Any

Attributes

Companion
class
Experimental
true
Source
VantagePointTree.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class VantagePointTree[V](elements: Seq[V], val distance: (V, V) => Double, val leafSize: Int = ...)

A vantage-point tree over elements: a static index for range and nearest-neighbour queries in any metric.

A vantage-point tree over elements: a static index for range and nearest-neighbour queries in any metric.

Each inner node holds one element (its vantage point) and splits the rest by distance to it, the nearer half to one child and the farther half to the other; the triangle inequality then lets a query skip a child without measuring its elements. Nodes with at most leafSize elements are scanned directly.

What a query returns does not depend on the tree's shape:

  • withinDistance(query, radius) is every element e with distance(query, e) &lt;= radius, the boundary included (the comparison is on the computed distance, so an element exactly at the radius is found), in the order of elements.
  • nearest(query, k) is the k elements nearest to query, nearest first, the first k of the stable sort of elements by distance: among elements at equal distance the one earlier in elements comes first. k larger than size returns all of them.

Both equal a linear scan whenever distance is a metric. Pruning compares distances with a relative slack of 1e-12, so the rounding of a computed metric (Euclidean distances violate the triangle inequality in the last bits) never hides an element. A distance that violates the triangle inequality by more than that (a correlation-derived dissimilarity, say) may make a query miss elements; use BruteForce for those.

The tree is built deterministically (a fixed pseudo-random choice of vantage points, a split at the median), is balanced whatever the data, and handles coincident elements: it builds in O(n log n) distance evaluations, a query costs O(log n) distance evaluations in low dimension. distance must be symmetric, non-negative and not NaN; infinite distances are allowed.

Type parameters

V

the element type, which is also the type of a query

Value parameters

distance

a metric on the elements

elements

the indexed elements; positions in this sequence are the indices the ...Indices queries return

leafSize

the largest number of elements scanned without further splitting (at least 1)

Attributes

Companion
object
Experimental
true
Source
VantagePointTree.scala
Supertypes
class Object
trait Matchable
class Any
object Vectorization

Fixed-size arrays of numbers from a barcode, for statistics and machine learning: persistence landscapes (Bubenik 2013), persistence images (Adams et al. 2017), Betti curves, persistence silhouettes (Chazal et al. 2014) and persistence entropy (Rucco et al. 2016).

Fixed-size arrays of numbers from a barcode, for statistics and machine learning: persistence landscapes (Bubenik 2013), persistence images (Adams et al. 2017), Betti curves, persistence silhouettes (Chazal et al. 2014) and persistence entropy (Rucco et al. 2016).

Essential bars count in landscape (their tent is the ramp t - birth, finite on any grid) and in bettiCurve (alive from their birth on); persistenceImage, silhouette and persistenceEntropy drop them (a Gaussian, a weight or a share of the total length at infinite persistence is not a number).

Attributes

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

The Vietoris-Rips complex, as a stream for any engine. (The Persistence verb is the shorter way to its diagram.)

The Vietoris-Rips complex, as a stream for any engine. (The Persistence verb is the shorter way to its diagram.)

maxDimension is the top homological degree: the stream holds one dimension more, so an engine run on it also reports classes of degree maxDimension + 1, which are incomplete; drop them. maxFiltrationValue defaults to the minimum enclosing radius (beyond it nothing new is born); pass Double.PositiveInfinity for the whole complex.

The constructions (Implementation) give the same complex, cell for cell, at different speeds; Implementation.RipserCoface is the default.

Attributes

Experimental
true
Source
VietorisRips.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object WeightedGraph

Attributes

Companion
class
Experimental
true
Source
WeightedGraph.scala
Supertypes
class Object
trait Matchable
class Any
Self type
class WeightedGraph extends FiniteMetricSpace[Int]

A weighted undirected graph on the vertices 0 until n, held as sorted neighbour lists: n + 2 m numbers for m edges, where a distance matrix holds n^2. It is a metric space in the sense the Vietoris-Rips machinery needs: the distance of two vertices is 0 for the same vertex, the weight of the edge between them, and Infinity where there is none (the triangle inequality does not hold; this is the combinatorial reading, the flag complex of the listed edges). Persistence(graph) computes that flag complex with FlagComplex, without ever forming a matrix.

A weighted undirected graph on the vertices 0 until n, held as sorted neighbour lists: n + 2 m numbers for m edges, where a distance matrix holds n^2. It is a metric space in the sense the Vietoris-Rips machinery needs: the distance of two vertices is 0 for the same vertex, the weight of the edge between them, and Infinity where there is none (the triangle inequality does not hold; this is the combinatorial reading, the flag complex of the listed edges). Persistence(graph) computes that flag complex with FlagComplex, without ever forming a matrix.

val graph = WeightedGraph(4, Seq((0, 1, 1.0), (1, 2, 1.5), (2, 3, 1.0), (3, 0, 2.0)))
Persistence(graph).dim(1)   // the square is a loop: born when its last edge enters, at 2.0, never filled

Attributes

See also

GraphMetric.geodesic for the shortest-path distances of a graph, which are a metric

Companion
object
Experimental
true
Source
WeightedGraph.scala
Supertypes
trait FiniteMetricSpace[Int]
class Object
trait Matchable
class Any

Attributes

Companion
class
Experimental
true
Source
WideSimplexIndexing.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class WideSimplexIndexing(val vertexCount: Int)

The combinatorial number system of SimplexIndexing with indices of up to 126 bits, for vertex counts and dimensions whose indices do not fit in a Long (SimplexIndexing.fitsLong). An index is two words, both non-negative: low holds its lowest 63 bits and high the bits above, so index order is the order of (high, low). The cursors find the same cofacets and facets as SimplexIndexing's, in the same order.

The combinatorial number system of SimplexIndexing with indices of up to 126 bits, for vertex counts and dimensions whose indices do not fit in a Long (SimplexIndexing.fitsLong). An index is two words, both non-negative: low holds its lowest 63 bits and high the bits above, so index order is the order of (high, low). The cursors find the same cofacets and facets as SimplexIndexing's, in the same order.

Attributes

Companion
object
Experimental
true
Source
WideSimplexIndexing.scala
Supertypes
class Object
trait Matchable
class Any
object Witness

The witness complex on chosen landmarks (vertex ids are LOCAL landmark indices 0 until landmarks.size).

The witness complex on chosen landmarks (vertex ids are LOCAL landmark indices 0 until landmarks.size).

Attributes

Experimental
true
Source
Complexes.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Witness.type

Attributes

Companion
class
Experimental
true
Source
WitnessStream.scala
Supertypes
class Object
trait Matchable
class Any
Self type
open class WitnessCofaceSimplexStream(val geometry: WitnessGeometry, maxFiltrationValue: Double = ..., keepCriterion: PartialFunction[Simplex[Int], Boolean] = ...) extends RipserCofaceSimplexStream

The general witness complex (JavaPlex's WitnessStream). Not a flag complex: a k-simplex is witnessed with a threshold depending on k (the (k+1)-th nearest landmark), so its filtration value is the larger of its own witness value and its facets' values (JavaPlex's addCofaces_), which makes the complex monotone. Its 1-skeleton is that of the lazy complex with nu = 2.

The general witness complex (JavaPlex's WitnessStream). Not a flag complex: a k-simplex is witnessed with a threshold depending on k (the (k+1)-th nearest landmark), so its filtration value is the larger of its own witness value and its facets' values (JavaPlex's addCofaces_), which makes the complex monotone. Its 1-skeleton is that of the lazy complex with nu = 2.

maxFiltrationValue defaults to Infinity: the enclosing radius is no cutoff for a complex that is not a flag complex. Without a finite value or a dimension cap, the stream enumerates every subset of the landmarks; Witness caps the dimension. Built through the companion apply, which builds the WitnessGeometry once.

Attributes

Companion
object
Experimental
true
Source
WitnessStream.scala
Supertypes
trait CofaceSimplexStream[Int, Double]
trait LevelwiseSimplexStream[Int, Double]
trait StratifiedCellStream[Simplex[Int], Double]
trait CellStream[Simplex[Int], Double]
trait IterableOnce[Simplex[Int]]
trait Filtration[Simplex[Int], Double]
trait Filterable[Double]
class Object
trait Matchable
class Any
Show all
open class WitnessGeometry(val ambientMetricSpace: FiniteMetricSpace[Int], val landmarks: IndexedSeq[Int])

The distances between landmarks and witnesses that a witness complex is built from (de Silva and Carlsson 2004; JavaPlex's WitnessStream). Every point is a witness, landmarks included. Landmark i (0 until landmarks.size) is point landmarks(i); D(l)(n) is the distance from landmark l to witness n, an L x N matrix built once. Assumes the metric space's elements are 0 until size.

The distances between landmarks and witnesses that a witness complex is built from (de Silva and Carlsson 2004; JavaPlex's WitnessStream). Every point is a witness, landmarks included. Landmark i (0 until landmarks.size) is point landmarks(i); D(l)(n) is the distance from landmark l to witness n, an L x N matrix built once. Assumes the metric space's elements are 0 until size.

Attributes

Experimental
true
Source
WitnessStream.scala
Supertypes
class Object
trait Matchable
class Any
open class WitnessMetricSpace(val geometry: WitnessGeometry, val nu: Int = ...) extends FiniteMetricSpace[Int]

The 1-skeleton of the lazy witness complex (JavaPlex's LazyWitnessStream) as a metric space on the landmark numbers: the lazy witness complex is the flag complex of this weighted graph, so any Vietoris-Rips machinery (including the Ripser engine) computes it.

The 1-skeleton of the lazy witness complex (JavaPlex's LazyWitnessStream) as a metric space on the landmark numbers: the lazy witness complex is the flag complex of this weighted graph, so any Vietoris-Rips machinery (including the Ripser engine) computes it.

Not a metric: two landmarks can be at distance 0, and the triangle inequality can fail. Use it only with the combinatorial Vietoris-Rips constructions, not with spatial data structures.

nu (0, 1 or 2, default 2) is JavaPlex's threshold: a witness sees a pair of landmarks at the distance to its nu-th nearest landmark beyond its own (0: no threshold, the smallest complex).

Attributes

Experimental
true
Source
WitnessStream.scala
Supertypes
trait FiniteMetricSpace[Int]
class Object
trait Matchable
class Any

Zigzag persistent homology: the homology of a sequence of complexes in which each is included in the next or the next in it, in either direction, as a barcode of intervals. A sequence K_0, K_1, ..., K_n is read in positions 0..n, and a bar [b, d) is a class that is in the homology of K_b, ..., K_{d-1} and in neither neighbour; the d of a class still there at K_n is infinite. With every arrow forward this is the ordinary barcode of a filtration with one cell, or one batch of cells, entering at each position.

Zigzag persistent homology: the homology of a sequence of complexes in which each is included in the next or the next in it, in either direction, as a barcode of intervals. A sequence K_0, K_1, ..., K_n is read in positions 0..n, and a bar [b, d) is a class that is in the homology of K_b, ..., K_{d-1} and in neither neighbour; the d of a class still there at K_n is infinite. With every arrow forward this is the ordinary barcode of a filtration with one cell, or one batch of cells, entering at each position.

val steps = Seq(Add(Simplex(0)), Add(Simplex(1)), Add(Simplex(0, 1)), Remove(Simplex(0, 1)))
val diagram = ZigzagPersistence(steps)

The input is a list of ZigzagSteps (apply), a list of complexes each included in the next or the next in it (ofComplexes), with the union or the intersection of consecutive complexes put between them when they are not (Link.Union, as for a time-varying point cloud). The result is an ordinary PersistenceDiagram: its bars have a representative, a cycle in the complex at the bar's birth, and every tool for diagrams applies.

The decomposition is made from left to right, one arrow at a time, on the homology of the complexes (Carlsson and de Silva): a basis of the homology at the current position, each class with its birth, in an order that the arrows decide (a class born by an arrow forward goes last, one born in the kernel of an arrow backward goes first). An arrow forward reduces the images of the classes in that order and the classes that vanish end. An arrow backward puts the classes of the smaller complex in the basis of the current homology, adapted to the order, and the classes outside its image end. Only the dimensions an arrow touches are recomputed, by sparse elimination on the boundary matrices of the larger complex of the arrow: each arrow costs a reduction of those, so the method is meant for sequences of up to a few thousand cells in the dimensions that change.

Attributes

Experimental
true
Source
ZigzagPersistence.scala
Supertypes
class Object
trait Matchable
class Any
Self type
enum ZigzagStep[CellT]

One step of a simplex-wise zigzag filtration: a cell enters the complex, or a cell leaves it.

One step of a simplex-wise zigzag filtration: a cell enters the complex, or a cell leaves it.

Attributes

Experimental
true
Source
ZigzagPersistence.scala
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Types

type BarcodeGenerators[FiltrationT, CellT, CoefficientT] = List[PersistenceBar[FiltrationT, Chain[CellT, CoefficientT]]]

Attributes

Source
Barcode.scala
opaque type Cube

An elementary cube: a product I_1 x ... x I_n of intervals, each a point [a, a] or a unit interval [a, a+1]. Its dimension is the number of unit intervals; n, the ambient dimension, is the same for every cube of a complex.

An elementary cube: a product I_1 x ... x I_n of intervals, each a point [a, a] or a unit interval [a, a+1]. Its dimension is the number of unit intervals; n, the ambient dimension, is the same for every cube of a complex.

Coordinates are doubled (Kaczynski, Mischaikow, Mrozek, ''Computational Homology''): [a, a] is 2a and [a, a+1] is 2a + 1, so a cube is one Vector[Int] (with structural equality, which the reductions rely on).

Attributes

Source
Cubical.scala
opaque type Simplex[VertexT]

Simplices really are just sets, outright. We provide an implementation of the [OrderedCell] typeclass for simplicial complex structures, to enable their use.

Simplices really are just sets, outright. We provide an implementation of the [OrderedCell] typeclass for simplicial complex structures, to enable their use.

Attributes

Source
Simplex.scala

Value members

Experimental methods

def cubeIsOrderedCell(setOrdering: Ordering[Cube] = ...): is[Cube, OrderedCell]

Cube is OrderedCell instance -- mirrors Simplex.scala's simplexIsOrderedCell parameterized-given pattern exactly, so a stream can inject its own filtration-aware ordering the same way EnumeratingCofaceSimplexStream etc. do for Simplex[Int].

Cube is OrderedCell instance -- mirrors Simplex.scala's simplexIsOrderedCell parameterized-given pattern exactly, so a stream can inject its own filtration-aware ordering the same way EnumeratingCofaceSimplexStream etc. do for Simplex[Int].

Boundary formula (Kaczynski-Mischaikow-Mrozek's standard cubical boundary operator, matching exactly what was asked for: "collapse each unit interval to a degenerate interval both ways, opposite signs, once per unit- interval factor"): for a cube with non-degenerate axes at positions p_1 &lt; p_2 &lt; ... &lt; p_d (0-indexed into the coordinate vector, d = the cube's own dimension), the boundary is

sum_{l=1}^{d} (-1)^(l-1) * (cube with axis p_l collapsed to its UPPER endpoint - cube with axis p_l collapsed to its LOWER endpoint)

i.e. the sign alternates over the RANK of the axis among non-degenerate axes (l, 0-indexed as rank below), not over its raw position in the coordinate vector -- using the raw position instead is a real, easy-to-make sign bug that breaks d(d(x)) = 0 as soon as a cube has a degenerate axis interleaved among its non-degenerate ones. Verified by CubicalSpec's dd=0 property test over a signed field (F3), not just F2 -- F2 cannot distinguish a correct alternating sign from a constant one, since -1 = 1 there.

Attributes

Experimental
true
Source
CubicalOrderedCell.scala
def cubeOrdering: Ordering[Cube]

cubeOrdering/cubeIsOrderedCell -- split into their own file from Cubical.scala (where the opaque type Cube and its companion live), for the same file-scoped opaque-transparency reason as SimplexOrderedCell.scala's split from Simplex.scala (see that file's doc). One wrinkle specific to Cube: boundary below builds new cube values via Cubical.scala's own top-level .asCube extension on Vector[Int], not a raw Vector[Int] =:= Cube coercion -- that coercion is only available inside Cubical.scala itself and cannot be exported.

cubeOrdering/cubeIsOrderedCell -- split into their own file from Cubical.scala (where the opaque type Cube and its companion live), for the same file-scoped opaque-transparency reason as SimplexOrderedCell.scala's split from Simplex.scala (see that file's doc). One wrinkle specific to Cube: boundary below builds new cube values via Cubical.scala's own top-level .asCube extension on Vector[Int], not a raw Vector[Int] =:= Cube coercion -- that coercion is only available inside Cubical.scala itself and cannot be exported.

Attributes

Experimental
true
Source
CubicalOrderedCell.scala
def simplexIsOrderedCell[VertexT](using vtxOrd: Ordering[VertexT])(setOrdering: Ordering[Simplex[VertexT]] = ...): is[Simplex[VertexT], OrderedCell]

Simplex[VertexT] is OrderedCell, with an injectable ordering so a stream can supply its own filtration order.

Simplex[VertexT] is OrderedCell, with an injectable ordering so a stream can supply its own filtration order.

Kept out of Simplex.scala: there the opaque type is transparent, and spx.size, spx - v would resolve to SortedSet's members instead of SimplexOps'.

Attributes

Experimental
true
Source
SimplexOrderedCell.scala
def simplexOrdering[VertexT](using vtxOrd: Ordering[VertexT]): Ordering[Simplex[VertexT]]

The lexicographic order of simplices, given an order of the vertices.

The lexicographic order of simplices, given an order of the vertices.

Attributes

Experimental
true
Source
Simplex.scala

Experimental fields

val ∆: Simplex.type

Convenience method for defining simplices

Convenience method for defining simplices

The character ∆ (U+2206 INCREMENT -- not the Greek capital Δ, U+0394) is typed as Alt+J on a Mac GB layout.

Attributes

Experimental
true
Source
Simplex.scala

Extensions

Experimental extensions

extension (coords: Vector[Int])
def asCube: Cube

Attributes

Experimental
true
Source
Cubical.scala
extension [VertexT](spx: Simplex[VertexT])
def max[B >: VertexT : Ordering]: VertexT

min and max of a simplex. Top-level rather than in object Simplex: a call site importing math.Ordering.Implicits.* would otherwise get that import's binary min/max, which is found first.

min and max of a simplex. Top-level rather than in object Simplex: a call site importing math.Ordering.Implicits.* would otherwise get that import's binary min/max, which is found first.

Attributes

Experimental
true
Source
SimplexOps.scala
def min[B >: VertexT : Ordering]: VertexT

min and max of a simplex. Top-level rather than in object Simplex: a call site importing math.Ordering.Implicits.* would otherwise get that import's binary min/max, which is found first.

min and max of a simplex. Top-level rather than in object Simplex: a call site importing math.Ordering.Implicits.* would otherwise get that import's binary min/max, which is found first.

Attributes

Experimental
true
Source
SimplexOps.scala
extension [VertexT](vertices: SortedSet[VertexT])
def asSimplex: Simplex[VertexT]

Attributes

Experimental
true
Source
Simplex.scala