pub struct BilinearInterp<T, const NX: usize, const NY: usize> { /* private fields */ }Expand description
Bilinear interpolant on a rectangular grid (fixed-size, stack-allocated).
Interpolates z = f(x, y) on an NX × NY grid by linearly interpolating first in x, then in y. Out-of-bounds queries extrapolate using the nearest boundary cell.
Internal storage is column-major: zs[ix][iy] holds the value at
(xs[ix], ys[iy]). The constructor accepts row-major input (each inner
array is a row at fixed y) and transposes internally, matching the
Matrix::new() convention.
§Example
use numeris::interp::BilinearInterp;
// 3×2 grid: z = x + y
let xs = [0.0_f64, 1.0, 2.0];
let ys = [0.0, 1.0];
// Row-major input: zs_input[iy][ix]
let zs = [
[0.0, 1.0, 2.0], // y = 0
[1.0, 2.0, 3.0], // y = 1
];
let interp = BilinearInterp::new(xs, ys, zs).unwrap();
assert!((interp.eval(0.5, 0.5) - 1.0).abs() < 1e-14);Implementations§
Source§impl<T: FloatScalar, const NX: usize, const NY: usize> BilinearInterp<T, NX, NY>
impl<T: FloatScalar, const NX: usize, const NY: usize> BilinearInterp<T, NX, NY>
Sourcepub fn new(
xs: [T; NX],
ys: [T; NY],
zs_rows: [[T; NX]; NY],
) -> Result<Self, InterpError>
pub fn new( xs: [T; NX], ys: [T; NY], zs_rows: [[T; NX]; NY], ) -> Result<Self, InterpError>
Construct a bilinear interpolant from sorted grid knots.
zs_rows[j][i] is the value at (xs[i], ys[j]) — row-major input.
Each inner array is a “row” of z-values at a fixed y-coordinate.
Internally transposed to column-major storage.
Returns InterpError::TooFewPoints if NX < 2 or NY < 2,
InterpError::NotSorted if xs or ys is not strictly increasing.
Trait Implementations§
Auto Trait Implementations§
impl<T, const NX: usize, const NY: usize> Freeze for BilinearInterp<T, NX, NY>where
T: Freeze,
impl<T, const NX: usize, const NY: usize> RefUnwindSafe for BilinearInterp<T, NX, NY>where
T: RefUnwindSafe,
impl<T, const NX: usize, const NY: usize> Send for BilinearInterp<T, NX, NY>where
T: Send,
impl<T, const NX: usize, const NY: usize> Sync for BilinearInterp<T, NX, NY>where
T: Sync,
impl<T, const NX: usize, const NY: usize> Unpin for BilinearInterp<T, NX, NY>where
T: Unpin,
impl<T, const NX: usize, const NY: usize> UnsafeUnpin for BilinearInterp<T, NX, NY>where
T: UnsafeUnpin,
impl<T, const NX: usize, const NY: usize> UnwindSafe for BilinearInterp<T, NX, NY>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.