slmsuite.holography.toolbox.smallest_distance#
- smallest_distance(vectors, metric='chebyshev')[source]#
Returns the smallest distance between pairs of points under a given
metric.Tip
This function supports a \(\mathcal{O}(N\log(N))\) divide and conquer algorithm and can handle large pointsets. An \(\mathcal{O}(N^2)\) brute force approach is implemented as a backup.
Caution
Vectors using unsigned datatypes can lead to unexpected results when evaluating a distance metric. Be sure that your vectors are signed.
- Parameters:
vectors (array_like) – Points to compare. Cleaned with
format_2vectors().metric (str OR function) – Function to use to compare. Defaults to
"chebyshev"which corresponds toscipy.spatial.distance.chebyshev(). The \(\mathcal{O}(N\log(N))\) divide and conquer algorithm is only compatible with string inputs allowed byscipy.spatial.distance.pdist(). Function arguments will fallback to the brute force approach.
- Returns:
Minimum distance between any pair of points under the given metric. If fewer than two points are given, then
np.infis returned.- Return type:
float