CircularCoordinates

org.appliedtopology.tda4j.CircularCoordinates

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

Members list

Type members

Classlikes

case class Result(theta: Map[Int, Double], birth: Double, death: Double, r: Double, prime: Int)

theta: ambient point index (matching the metricSpace passed to compute) to its circle coordinate in [0, 1) -- only for points in the connected component of K_r containing the chosen class (see the class doc); a point outside that component has no entry at all, not a sentinel value. For sparse coordinates, the points that the balls of radius r around that component's landmarks cover. birth/death are the chosen bar's own full-filtration endpoints (death = Double.PositiveInfinity for an essential bar); r and prime echo the parameters compute was called with.

theta: ambient point index (matching the metricSpace passed to compute) to its circle coordinate in [0, 1) -- only for points in the connected component of K_r containing the chosen class (see the class doc); a point outside that component has no entry at all, not a sentinel value. For sparse coordinates, the points that the balls of radius r around that component's landmarks cover. birth/death are the chosen bar's own full-filtration endpoints (death = Double.PositiveInfinity for an essential bar); r and prime echo the parameters compute was called with.

Attributes

Source
CircularCoordinates.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class ToroidalResult(theta: IndexedSeq[Map[Int, Double]], cocycleIndices: IndexedSeq[Int], basisChange: Array[Array[Int]], originalGram: Array[Array[Double]], reducedGram: Array[Array[Double]], r: Double, prime: Int)

theta: one map per combined coordinate (same shape/semantics as Result's own theta, in the SAME order as cocycleIndices), giving a joint torus-valued map K_r's shared connected component -> (R/Z)^k. basisChange is LatticeReduction.Result.basisChange: column c's coordinates express the c-th returned coordinate as an integer combination of the ORIGINAL cocycleIndices-ordered classes (the identity matrix if reduce = false or only one class was chosen). originalGram/reducedGram are the chosen classes' own harmonic-representative Gram matrix before/after reduction -- smaller off-diagonal entries in reducedGram is the evidence the reduction actually decorrelated the coordinates on this data, and originalGram == reducedGram (up to a signed permutation) means the raw persistent-cohomology basis was already about as good as it gets here.

theta: one map per combined coordinate (same shape/semantics as Result's own theta, in the SAME order as cocycleIndices), giving a joint torus-valued map K_r's shared connected component -> (R/Z)^k. basisChange is LatticeReduction.Result.basisChange: column c's coordinates express the c-th returned coordinate as an integer combination of the ORIGINAL cocycleIndices-ordered classes (the identity matrix if reduce = false or only one class was chosen). originalGram/reducedGram are the chosen classes' own harmonic-representative Gram matrix before/after reduction -- smaller off-diagonal entries in reducedGram is the evidence the reduction actually decorrelated the coordinates on this data, and originalGram == reducedGram (up to a signed permutation) means the raw persistent-cohomology basis was already about as good as it gets here.

Attributes

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

Value members

Concrete methods

def apply(diagram: PersistenceDiagram[Simplex[Int]], input: Input[Simplex[Int]], bar: Int = ..., r: Optional[Double] = ..., complex: PointCloudComplex = ...): Result

Circular coordinates for one H¹ bar of a persistence diagram: the loop diagram.dim(1) found, whichever complex and engine found it.

Circular coordinates for one H¹ bar of a persistence diagram: the loop diagram.dim(1) found, whichever complex and engine found it.

val diagram = Persistence(points, maxDimension = 1)
val coordinate = CircularCoordinates(diagram, points)       // the most persistent loop, at the middle of its bar
CircularCoordinates(diagram, points, bar = 1, r = 0.6)      // another loop, at a chosen scale
CircularCoordinates(cechDiagram, points, complex = Cech)    // a Cech diagram: say which complex it is of

The scale r and the cocycle are read off the diagram where they can be. With representatives = Representatives.Cocycles the bar's own cocycle is restricted to the complex at r and used as it is. A diagram of cycles (the default of Persistence), or one that does not say, has its class recovered by the cohomology of that complex over the diagram's field, matched to the bar by its birth. Either way the cocycle is lifted to the integers, checked there, and smoothed to the harmonic representative as in compute.

Value parameters

bar

the bar, counted among the diagram's H¹ bars from the most persistent, as in h1Bars.

complex

the complex a point cloud is turned into, as in Persistence(points, complex = ...).

diagram

a diagram of degrees up to at least 1, over Z/p for an odd prime p (the characteristic it was computed with), of a complex on integer vertices.

input

what the diagram was computed from, as Persistence took it: points, a metric space or a stream.

r

the scale to compute at; it must lie in [birth, death) of the bar (default: the middle of the bar, or the end of the diagram for a bar that never dies).

Attributes

Source
CircularCoordinates.scala
def compute(metricSpace: FiniteMetricSpace[Int], r: Double, cocycleIndex: Int = ..., prime: Int = ..., maxFiltrationValue: Optional[Double] = ..., numLandmarks: Int = ...): Result

Circular coordinates for one persistent H¹ class of the Vietoris-Rips complex of metricSpace.

Circular coordinates for one persistent H¹ class of the Vietoris-Rips complex of metricSpace.

Value parameters

cocycleIndex

the class, 0 being the most persistent (as in h1Bars and DREiMac's cocycle_idx).

maxFiltrationValue

the truncation of the full computation that finds the classes (default: the minimum enclosing radius; with landmarks, the radius at which one point sees them all).

metricSpace

the points, or a metric space.

numLandmarks

0 (the default) for the coordinates of the complex on every point; n for Perea's sparse coordinates over n maxmin landmarks (the class doc), much cheaper for many points. The classes and r are then those of h1Bars(metricSpace, numLandmarks = n).

prime

the odd prime cohomology is computed over before the cocycle is lifted to the integers (F_2 would admit classes with no lift). If NoIntegerCocycleException is thrown for a class that is not torsion, try a larger one.

r

the scale at which the coordinates are computed; it must lie in [birth, death) of the chosen class (the error names that range otherwise).

Attributes

Source
CircularCoordinates.scala
def computeToroidal(metricSpace: FiniteMetricSpace[Int], r: Double, cocycleIndices: Seq[Int], prime: Int = ..., reduce: Boolean = ..., maxFiltrationValue: Optional[Double] = ..., numLandmarks: Int = ...): ToroidalResult

Toroidal coordinates (Scoccola, Gakhar, Bush, Schonsheck, Rask, Zhou, Perea, "Toroidal Coordinates: Decorrelating Circular Coordinates With Lattice Reduction", arXiv:2212.07201): circular coordinates for several H¹ classes alive at r, combined into one map to a torus.

Toroidal coordinates (Scoccola, Gakhar, Bush, Schonsheck, Rask, Zhou, Perea, "Toroidal Coordinates: Decorrelating Circular Coordinates With Lattice Reduction", arXiv:2212.07201): circular coordinates for several H¹ classes alive at r, combined into one map to a torus.

Any unimodular integer recombination of k classes generates the same lattice of classes, so the k coordinates a cohomology computation returns are an arbitrary choice. This picks the shortest, most nearly orthogonal recombination (LatticeReduction, LLL) under the inner product of the harmonic representatives.

Value parameters

cocycleIndices

the classes (indexed as in h1Bars), at least one and without repeats. Each bar must contain r, and all of them must live on the same connected component of K_r.

numLandmarks

0 (the default) for the complex on every point, n for Perea's sparse coordinates over n maxmin landmarks, as in compute.

reduce

false returns the coordinates of the classes as given, without recombining them (basisChange is then the identity).

Attributes

Source
CircularCoordinates.scala
def h1Bars(metricSpace: FiniteMetricSpace[Int], maxFiltrationValue: Optional[Double] = ..., numLandmarks: Int = ...): IndexedSeq[(Double, Double)]

The (birth, death) of every persistent H¹ class of the Vietoris-Rips complex of metricSpace, most persistent first: index i is cocycleIndex = i in compute. Call this first to choose r. With numLandmarks = n, those of the nerve of the balls around n maxmin landmarks, which compute with the same numLandmarks uses: there a scale is a ball's radius.

The (birth, death) of every persistent H¹ class of the Vietoris-Rips complex of metricSpace, most persistent first: index i is cocycleIndex = i in compute. Call this first to choose r. With numLandmarks = n, those of the nerve of the balls around n maxmin landmarks, which compute with the same numLandmarks uses: there a scale is a ball's radius.

Attributes

Source
CircularCoordinates.scala
def h1Bars(diagram: PersistenceDiagram[Simplex[Int]]): IndexedSeq[(Double, Double)]

The (birth, death) of every H¹ bar of diagram, most persistent first: index i is bar = i in apply and toroidal. Call this first to choose r.

The (birth, death) of every H¹ bar of diagram, most persistent first: index i is bar = i in apply and toroidal. Call this first to choose r.

Attributes

Source
CircularCoordinates.scala
def harmonicSmoothOnComponent(krStream: CellStream[Simplex[Int], Double], zInt: Map[Simplex[Int], Int])(using is[Double, Field]): (Map[Int, Double], Map[Simplex[Int], Double], Set[Simplex[Int]])

Given K_r and an ALREADY-VALIDATED integer 1-cochain zInt (a genuine integer cocycle on krStream, see verifyIntegerCocycle -- this method itself does no cocycle-condition checking), performs the harmonic smoothing (see class doc: min_g ||z - d0 g||^2, anchored at one component vertex) and returns the resulting circular coordinate theta(v) = frac(g(v)) alongside the harmonic cochain h = z - d0 g itself (as a value on every edge of the component, including edges where zInt is zero -- h is generally NONZERO there too) and the connected component of krStream's 1-skeleton the whole computation was restricted to. Factored out of computeGeneric (which calls this for a single already-matched class) so computeToroidalGeneric can call it once per SIMULTANEOUSLY-chosen class on the SAME krStream -- the harmonic cochain h is exactly the vector LatticeReduction's Gram matrix is built from (the paper's own dSMV inner product is the plain sum-over-edges dot product of these).

Given K_r and an ALREADY-VALIDATED integer 1-cochain zInt (a genuine integer cocycle on krStream, see verifyIntegerCocycle -- this method itself does no cocycle-condition checking), performs the harmonic smoothing (see class doc: min_g ||z - d0 g||^2, anchored at one component vertex) and returns the resulting circular coordinate theta(v) = frac(g(v)) alongside the harmonic cochain h = z - d0 g itself (as a value on every edge of the component, including edges where zInt is zero -- h is generally NONZERO there too) and the connected component of krStream's 1-skeleton the whole computation was restricted to. Factored out of computeGeneric (which calls this for a single already-matched class) so computeToroidalGeneric can call it once per SIMULTANEOUSLY-chosen class on the SAME krStream -- the harmonic cochain h is exactly the vector LatticeReduction's Gram matrix is built from (the paper's own dSMV inner product is the plain sum-over-edges dot product of these).

Attributes

Source
CircularCoordinates.scala
def sparse(diagram: PersistenceDiagram[Simplex[Int]], relation: Array[Array[Double]], bar: Int = ..., r: Optional[Double] = ...): Result

Perea's sparse circular coordinates for one H¹ bar of the Dowker diagram of relation (see the class doc): rows are landmarks, or any cover, columns the points, and relation(l)(x) < r puts point x in the cover set of l. The coordinate is computed on the nerve of the cover at r, and every point that cover sets of the loop's connected component hold gets one.

Perea's sparse circular coordinates for one H¹ bar of the Dowker diagram of relation (see the class doc): rows are landmarks, or any cover, columns the points, and relation(l)(x) < r puts point x in the cover set of l. The coordinate is computed on the nerve of the cover at r, and every point that cover sets of the loop's connected component hold gets one.

val geometry = WitnessGeometry(metricSpace, landmarks)   // the distances from each landmark to every point
val diagram = Persistence(Dowker(geometry.D, maxDimension = 1))
CircularCoordinates.sparse(diagram, geometry.D).theta     // a coordinate for every point

Value parameters

bar

the bar, counted among the diagram's H¹ bars from the most persistent, as in h1Bars.

diagram

the diagram of Dowker(relation, ...) (on the rows, dual = false), with degrees up to at least 1, over Z/p for an odd prime p. With cocycles its own are used, otherwise they are recovered as in apply.

r

the radius of the cover sets; it must lie in [birth, death) of the bar (default: the middle of the bar).

Attributes

Source
CircularCoordinates.scala
def sparseToroidal(diagram: PersistenceDiagram[Simplex[Int]], relation: Array[Array[Double]], bars: Seq[Int], r: Optional[Double] = ..., reduce: Boolean = ...): ToroidalResult

toroidal with sparse coordinates: several H¹ bars of the Dowker diagram of relation, alive together at r, combined into one torus-valued map on every point the cover holds, as sparse does for one.

toroidal with sparse coordinates: several H¹ bars of the Dowker diagram of relation, alive together at r, combined into one torus-valued map on every point the cover holds, as sparse does for one.

Attributes

Source
CircularCoordinates.scala
def toroidal(diagram: PersistenceDiagram[Simplex[Int]], input: Input[Simplex[Int]], bars: Seq[Int], r: Optional[Double] = ..., complex: PointCloudComplex = ..., reduce: Boolean = ...): ToroidalResult

Toroidal coordinates for several H¹ bars of a persistence diagram, as computeToroidal does for a metric space: the bars must be alive together at r and on one connected piece of the complex.

Toroidal coordinates for several H¹ bars of a persistence diagram, as computeToroidal does for a metric space: the bars must be alive together at r and on one connected piece of the complex.

Value parameters

bars

the bars, counted as in h1Bars; at least one, without repeats.

r

the scale (default: the middle of the stretch where all the bars are alive).

reduce

false keeps the classes as given, without the lattice reduction.

Attributes

Source
CircularCoordinates.scala