WitnessGeometry

org.appliedtopology.tda4j.streams.WitnessGeometry
class WitnessGeometry(val ambientMetricSpace: FiniteMetricSpace[Int], val landmarks: IndexedSeq[Int])

Precomputes and exposes the landmarkwitness distance geometry a witness complex is built from (De Silva & Carlsson 2004; checked against JavaPlex's own WitnessStream/LazyWitnessStream -- see .claude/WORKLOG-witness-complex.md). Every point of ambientMetricSpace is a witness (landmarks included, matching JavaPlex's own plex3Compatible = true default), and landmarks is a subset of ambientMetricSpace's own ambient indices -- LOCAL landmark index i (0 until landmarks.size) corresponds to ambient index landmarks(i). Assumes ambientMetricSpace.elements == 0 until ambientMetricSpace.size (see LandmarkSelector's own doc for why that's not a new assumption).

D(l)(n) is the distance from landmark l (local index) to witness n (ambient index) -- built once, eagerly: an L x N matrix, exactly JavaPlex's own D. O(L*N) space/time, unavoidable since the witness-value formula below reads a whole row per candidate landmark.

Attributes

Experimental
true
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def mDim(k: Int, witness: Int): Double

The (k+1)-th nearest landmark's distance to witness n (0-indexed: mDim(0, n) is the nearest-landmark distance). Valid for 0 <= k < L. This is JavaPlex's WitnessStream.m[k][n] -- no sentinel zero prepended, unlike WitnessMetricSpace.mNu below (that sentinel is a LazyWitnessStream-only device).

The (k+1)-th nearest landmark's distance to witness n (0-indexed: mDim(0, n) is the nearest-landmark distance). Valid for 0 <= k < L. This is JavaPlex's WitnessStream.m[k][n] -- no sentinel zero prepended, unlike WitnessMetricSpace.mNu below (that sentinel is a LazyWitnessStream-only device).

Attributes

def witnessValue(sigma: IndexedSeq[Int], m: Int => Double): Double

The De Silva-Carlsson witness value for the landmark set sigma (local indices), given a per-witness threshold function m: min over witnesses n of max(0, (max over l in sigma of D(l,n)) - m(n)). Shared by both WitnessMetricSpace (edges, m = m_nu, one global nu) and WitnessCofaceSimplexStream (a k-dimensional simplex, m = m_k) -- JavaPlex's own getWitnessAndDistance/addCofaces_ formula. Clamping max(0, ...) PER WITNESS before taking the min, rather than clamping the min's own result, matches JavaPlex's code exactly and is provably equivalent (max(0, *) is monotone nondecreasing, and a monotone function commutes with min) -- see .claude/WORKLOG-witness-complex.md.

The De Silva-Carlsson witness value for the landmark set sigma (local indices), given a per-witness threshold function m: min over witnesses n of max(0, (max over l in sigma of D(l,n)) - m(n)). Shared by both WitnessMetricSpace (edges, m = m_nu, one global nu) and WitnessCofaceSimplexStream (a k-dimensional simplex, m = m_k) -- JavaPlex's own getWitnessAndDistance/addCofaces_ formula. Clamping max(0, ...) PER WITNESS before taking the min, rather than clamping the min's own result, matches JavaPlex's code exactly and is provably equivalent (max(0, *) is monotone nondecreasing, and a monotone function commutes with min) -- see .claude/WORKLOG-witness-complex.md.

Attributes

Concrete fields

val D: Array[Array[Double]]
val L: Int
val N: Int
val landmarks: IndexedSeq[Int]