Class Bandwidth::BoxBounder
Defined in File Bandwidth.hpp
Nested Relationships
This class is a nested type of Class Bandwidth.
Class Documentation
-
class BoxBounder
Rigorous lower and upper bounds on the distance from one point to axis-aligned boxes.
Built once per search point (see Bandwidth::boxBounder()). With s the specified dimensions, the bound uses a factor W of the matrix’s s-s block, M_s = W^T W, from Eigen’s pivoted LDL^T factorization M_s = P^T L D L^T P, W = D^1/2 L^T P. For any y, (x - y)^T M_s (x - y) = sum_k (w_k . (x - y))^2, where w_k are the rows of W. Over a box with center c and half-widths h, w_k . y covers exactly the interval w_k . c +- |w_k| . h, so the minimum of each term over the box is the squared gap between w_k . x and that interval (zero if it lies inside); their sum is a rigorous lower bound on the minimum of the sum, and exact for a diagonal metric (which uses a direct O(n) path instead). Likewise the maximum of each term is the squared distance from w_k . x to the far end of the interval, (|w_k . x - w_k . c| + |w_k| . h)^2, and their sum is a rigorous upper bound on the maximum of the sum (the per-term maxima generally occur at different points of the box), again exact for a diagonal metric, where it is the distance to the box’s farthest corner. A triangular, Cholesky-type factor is used rather than the metric’s principal axes because it stays close to the coordinate axes as the metric approaches diagonal, keeping the bound tight; the principal axes can rotate arbitrarily when eigenvalues are nearly equal. For non-diagonal metrics the lower bound is shrunk, and the upper bound inflated, by a relative 1e-10, so that rounding in the factorization can never carry either past a true distance. Holds scratch space, so must not be shared between threads; must not outlive the Bandwidth it came from.
Public Functions
-
auto lower(std::span<const double> lo, std::span<const double> hi) const -> double
Lower bound on the squared distance from the point to a box.
- Parameters:
lo – Lower corner of the box (n elements)
hi – Upper corner of the box (n elements)
- Returns:
A value no larger than the squared distance (as computed by dist2()) from the point to any point in the box
-
inline auto nDim() const -> std::size_t
Number of dimensions of the boxes.
- Returns:
The Bandwidth’s number of dimensions, n
-
auto upper(std::span<const double> lo, std::span<const double> hi) const -> double
Upper bound on the squared distance from the point to a box.
- Parameters:
lo – Lower corner of the box (n elements)
hi – Upper corner of the box (n elements)
- Returns:
A value no smaller than the squared distance (as computed by dist2()) from the point to any point in the box
-
auto bounds(std::span<const double> lo, std::span<const double> hi) const -> std::pair<double, double>
Lower and upper bounds together.
- Parameters:
lo – Lower corner of the box (n elements)
hi – Upper corner of the box (n elements)
- Returns:
The pair (lower(lo, hi), upper(lo, hi)), computed with a single pass over the box, so cheaper than calling both separately
-
auto lower(std::span<const double> lo, std::span<const double> hi) const -> double