EuclideanMetricSpace

org.appliedtopology.tda4j.EuclideanMetricSpace
See theEuclideanMetricSpace companion object
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 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
Graph
Supertypes
trait FiniteMetricSpace[Int]
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def contains(x: Int): Boolean

Attributes

Definition Classes
Source
FiniteMetricSpace.scala
def distance(x: Int, y: Int): Double

Distance in the metric space. Takes two indices and returns a non-negative real number.

Distance in the metric space. Takes two indices and returns a non-negative real number.

Value parameters

x

Index of first point

y

Index of second point

Attributes

Returns

Distance between x and y

Source
FiniteMetricSpace.scala
def elements: Iterable[Int]

Access to all points in the metric space. Implemented by eg scala.collections.Range for simple Int-indexed spaces, but this definition gives more space for different underlying possible representations.

Access to all points in the metric space. Implemented by eg scala.collections.Range for simple Int-indexed spaces, but this definition gives more space for different underlying possible representations.

Attributes

Returns

Iterable that returns all points in the metric space

Source
FiniteMetricSpace.scala
def longestDistanceByQueries(threshold: Double): Option[Double]

The longest distance at most threshold by one query per point on a vantage-point tree, the points on all threads; None when a point has so many others within reach that the tree stops paying (a query that would measure more than a quarter of the points is given up, and with it the whole search): the cost of a point is then about the cost of scanning the points once, so the queries would cost as much as the pass over all pairs.

The longest distance at most threshold by one query per point on a vantage-point tree, the points on all threads; None when a point has so many others within reach that the tree stops paying (a query that would measure more than a quarter of the points is given up, and with it the whole search): the cost of a point is then about the cost of scanning the points once, so the queries would cost as much as the pass over all pairs.

Attributes

Source
FiniteMetricSpace.scala
def longestDistanceByRows(threshold: Double): Double

The longest distance at most threshold by the pass over all pairs, one task per point (its pairs with the points after it), the tasks shared between all threads.

The longest distance at most threshold by the pass over all pairs, one task per point (its pairs with the points after it), the tasks shared between all threads.

Attributes

Source
FiniteMetricSpace.scala
override def longestDistanceWithin(threshold: Double): Double

The same number as FiniteMetricSpace.longestDistanceWithin. Up to EuclideanMetricSpace.MaxCachedPoints points the pass over the pairs is cheap, and it runs as it does for any space. Above that, the distances are not cached and the pass costs n^2 / 2 of them, so it is replaced by one query per point on the vantage-point tree (longestDistanceByQueries), which costs a few hundred distances per point on a cloud where the threshold keeps few of the pairs, and that is where a long run is. Where it keeps many, the pass runs as one task per point on all threads (longestDistanceByRows).

The same number as FiniteMetricSpace.longestDistanceWithin. Up to EuclideanMetricSpace.MaxCachedPoints points the pass over the pairs is cheap, and it runs as it does for any space. Above that, the distances are not cached and the pass costs n^2 / 2 of them, so it is replaced by one query per point on the vantage-point tree (longestDistanceByQueries), which costs a few hundred distances per point on a cloud where the threshold keeps few of the pairs, and that is where a long run is. Where it keeps many, the pass runs as one task per point on all threads (longestDistanceByRows).

Attributes

Definition Classes
Source
FiniteMetricSpace.scala
def neighbors(qp: Array[Double], eps: Double): Seq[Int]

The indices of the points within distance eps of qp (ascending), qp itself need not be one of them.

The indices of the points within distance eps of qp (ascending), qp itself need not be one of them.

Attributes

Source
FiniteMetricSpace.scala
def neighbourListsByQueries(threshold: Double, maxEntries: Long): Option[NeighbourLists]

The neighbour lists by one query per point (see neighbourListsWithin), whatever the size of the space.

The neighbour lists by one query per point (see neighbourListsWithin), whatever the size of the space.

Attributes

Source
FiniteMetricSpace.scala
override def neighbourListsWithin(threshold: Double, maxEntries: Long): Option[NeighbourLists]

The same lists as NeighbourLists.within(size, threshold, maxEntries)(distance), found by one query per point on the vantage-point tree, the points on all threads, when the space is too big to cache its distances (above that the pass costs n^2 / 2 distances and the queries a few hundred per point). None below that size, when a query would measure more than a quarter of the points (the tree stops paying: the same rule as longestDistanceByQueries), or when there are more than maxEntries directed pairs.

The same lists as NeighbourLists.within(size, threshold, maxEntries)(distance), found by one query per point on the vantage-point tree, the points on all threads, when the space is too big to cache its distances (above that the pass costs n^2 / 2 distances and the queries a few hundred per point). None below that size, when a query would measure more than a quarter of the points (the tree stops paying: the same rule as longestDistanceByQueries), or when there are more than maxEntries directed pairs.

Attributes

Definition Classes
Source
FiniteMetricSpace.scala
def point(index: Int): Array[Double]

A copy of the coordinates of point index.

A copy of the coordinates of point index.

Attributes

Source
FiniteMetricSpace.scala
def pointSqDistance(x: Array[Double], y: Array[Double]): Double

The squared distance between two points, which must have the same number of coordinates.

The squared distance between two points, which must have the same number of coordinates.

Attributes

Source
FiniteMetricSpace.scala
def pts: Array[Array[Double]]

A copy of all the points: n arrays are allocated on every call, so read single points with point.

A copy of all the points: n arrays are allocated on every call, so read single points with point.

Attributes

Source
FiniteMetricSpace.scala
def size: Int

Number of points represented by this metric space.

Number of points represented by this metric space.

Attributes

Source
FiniteMetricSpace.scala

Concrete fields

val cacheDistances: Boolean

Attributes

Source
FiniteMetricSpace.scala
lazy val vpdf: (Array[Double], Array[Double]) => Double

The Euclidean distance between two points, the metric of vpt.

The Euclidean distance between two points, the metric of vpt.

Attributes

Source
FiniteMetricSpace.scala
lazy val vpt: VantagePointTree[Array[Double]]

A vantage-point tree over the points.

A vantage-point tree over the points.

Attributes

Source
FiniteMetricSpace.scala

Inherited fields

lazy val minimumEnclosingRadius: Double

Beyond this radius, the Vietoris-Rips complex is a cone and will have no further homological structure. See e.g. the Ripser paper, page 412. The same holds for the Cech and alpha complexes, whose union of balls is then contractible, so no barcode changes past it: it is the radius that Persistence runs to when it is not told another. A space with infinite distances (a sparse distance matrix: a pair that is not listed has no edge) has no such cone; its radius is then the largest finite distance, past which nothing enters.

Beyond this radius, the Vietoris-Rips complex is a cone and will have no further homological structure. See e.g. the Ripser paper, page 412. The same holds for the Cech and alpha complexes, whose union of balls is then contractible, so no barcode changes past it: it is the radius that Persistence runs to when it is not told another. A space with infinite distances (a sparse distance matrix: a pair that is not listed has no edge) has no such cone; its radius is then the largest finite distance, past which nothing enters.

Found by looking for the point whose farthest point is nearest, with no allocation, and giving up on a point as soon as a point at least as far as the best so far turns up: on spread-out points that takes a handful of distances per point, not all of them.

Attributes

Inherited from:
FiniteMetricSpace
Source
FiniteMetricSpace.scala