MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / dsLowerBound

Function dsLowerBound

app/src/DSP.h:852–869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

850 */
851template<typename XAt>
852[[nodiscard]] inline std::size_t dsLowerBound(std::size_t n, XAt xAt, const ssfp_t bound)
853{
854 std::size_t lo = 0;
855 std::size_t len = n;
856 for (int step = 0; step < 64 && len > 0; ++step) {
857 const std::size_t half = len / 2;
858 const std::size_t mid = lo + half;
859 if (xAt(mid) < bound) {
860 lo = mid + 1;
861 len = len - half - 1;
862 }
863
864 else
865 len = half;
866 }
867
868 return lo;
869}
870
871/**
872 * @brief First index in [0, n) whose X value is > bound. Binary search: X must be

Callers 2

downsampleTimeWindowFunction · 0.85
downsampleWindowAbsoluteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected