Function utils::findBracket
Defined in File GridBracket.hpp
Function Documentation
-
auto utils::findBracket(const std::vector<double> &grid, double value, std::size_t &cacheIdx) -> Bracket
Find the bracketing grid points of a sorted grid.
Locates the bracket via a binary search accelerated by cacheIdx – see GridBracket.cpp’s own definition for the full rationale. Shared by every tensor-grid interpolator in this codebase (the spectral synthesis libraries in src/specsyn, and yields::YieldChannel) rather than each reimplementing its own copy of the same bracket-search logic.
- Parameters:
grid – A sorted (ascending), non-empty grid of values
value – The query value; assumed to already lie within [grid.front(), grid.back()]
cacheIdx – The calling thread’s cached bracket index for this axis (e.g. one element of a ThreadVec<size_t>, already resolved to the element private to this thread); updated in place to the bracket this call finds, so the next call – if its own query value is still within, or close to, this same cell – can reuse it
- Returns:
The bracketing Bracket for value