cheby 0.2.0

Unit-safe Chebyshev approximation and spectral numerics for Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! Segment lookup helpers.

use crate::core::ChebyTime;

/// Compute a uniform segment index for `x`.
#[inline]
pub fn uniform_index<X: ChebyTime>(start: X, segment_len: X, len: usize, x: X) -> Option<usize> {
    if len == 0 || x < start {
        return None;
    }
    let idx = ((x - start) / segment_len).floor() as usize;
    (idx < len).then_some(idx)
}