pos_search

Function pos_search 

Source
pub fn pos_search(x: f64, xs: &[f64]) -> usize
Expand description

Finds the position for interpolation in a sorted array.

Returns the index of the largest element in xs that is less than x, clamped to the valid range [0, xs.len() - 1].

ยงEdge Cases

  • For empty arrays, returns 0
  • For single-element arrays, always returns index 0, regardless of whether x > xs[0]
  • For values below the minimum, returns 0
  • For values at or above the maximum, returns xs.len() - 1