pulsatrix 1.1.0
Loading...
Searching...
No Matches
landmarks.hpp
Go to the documentation of this file.
1
17#pragma once
18
19#include <cstdint>
20#include <vector>
21
25#include "pulsatrix/tensor.hpp"
26
27namespace pulsatrix {
28
32 int64_t count = 0;
34 double radius = 0;
36 int64_t first = 0;
39 bool center = false;
40};
41
43struct Landmarks {
45 std::vector<int64_t> indices;
47 std::vector<int64_t> nearest;
49 std::vector<double> distance_to_nearest;
53 std::vector<double> insertion_radii;
58
61 [[nodiscard]] ErrorTerm SubsamplingTerm() const {
62 return {"landmark subsampling: twice the covering radius", 2 * (covering_radius.value + covering_radius.bound())};
63 }
64};
65
75[[nodiscard]] Landmarks FarthestPointLandmarks(const Tensor& points, const LandmarkOptions& options);
76
78[[nodiscard]] Landmarks FarthestPointLandmarks(const PointCloud& cloud, DeviceBackend* backend,
79 const LandmarkOptions& options);
80
82[[nodiscard]] Tensor LandmarkPoints(const Tensor& points, const Landmarks& landmarks);
83
90
91} // namespace pulsatrix
Vendor-agnostic compute/memory backend. CPUBackend, CUDABackend (Phase 1.5), and HIPBackend (Phase 1....
Definition device_backend.hpp:248
A set of points in R^dimension, built from activation batches.
Definition point_cloud.hpp:86
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
Distances between persistence diagrams, bottleneck and Wasserstein, and Certified<T>,...
Definition acquisition_functions.hpp:16
PersistenceDiagram WithSubsamplingBound(PersistenceDiagram diagram, const Landmarks &landmarks)
A diagram of the landmarks re-certified against the whole cloud: its error_bound becomes its own plus...
Tensor LandmarkPoints(const Tensor &points, const Landmarks &landmarks)
The landmark rows of points, as a (k, ...) tensor on points' backend.
Landmarks FarthestPointLandmarks(const Tensor &points, const LandmarkOptions &options)
Picks farthest-point landmarks among the rows of points.
A persistence diagram: the features of one homology dimension, each born at one scale and dying at a ...
The input to topological data analysis: a layer's activations as a set of points, one row per input o...
A computed value and a certified bound on its error, itemized by source: the exact value is within bo...
Definition diagram_distance.hpp:40
T value
The value as computed.
Definition diagram_distance.hpp:42
double bound() const
The total bound: the sum of the terms.
Definition diagram_distance.hpp:47
One source of error in a Certified value.
Definition diagram_distance.hpp:28
FarthestPointLandmarks()'s settings. Selection stops at whichever limit comes first.
Definition landmarks.hpp:30
int64_t first
The first landmark.
Definition landmarks.hpp:36
double radius
Stop once every point is within this distance of a landmark; 0 for no limit.
Definition landmarks.hpp:34
int64_t count
The most landmarks to pick; 0 for no limit (then radius must be set).
Definition landmarks.hpp:32
bool center
Subtract the mean point first: Euclidean distances are unchanged, and the float32 error shrinks when ...
Definition landmarks.hpp:39
FarthestPointLandmarks()'s result.
Definition landmarks.hpp:43
ErrorTerm SubsamplingTerm() const
The error term subsampling adds to a diagram of the landmarks, as a bound on its bottleneck distance ...
Definition landmarks.hpp:61
std::vector< double > distance_to_nearest
For each point, its distance to that landmark.
Definition landmarks.hpp:49
std::vector< int64_t > indices
The landmarks' row indices, in the order they were picked.
Definition landmarks.hpp:45
Certified< double > covering_radius
The covering radius, max over points of distance_to_nearest, with the float32 error of the distances ...
Definition landmarks.hpp:57
std::vector< int64_t > nearest
For each point, the position in indices of its nearest landmark.
Definition landmarks.hpp:47
std::vector< double > insertion_radii
insertion_radii[k]: the covering radius before landmark k was added, which is its distance to the lan...
Definition landmarks.hpp:53
The features of one homology dimension: H0 for components, H1 for loops, H2 for voids.
Definition persistence_diagram.hpp:32
N-dimensional tensor – owns a buffer via DeviceBackend*, RAII (Rule of Five).