interpn
N-dimensional interpolation/extrapolation methods, no-std and no-alloc compatible, prioritizing correctness, performance, and compatiblity with memory-constrained environments.
Performance Scalings
Note that for a self-consistent multidimensional interpolation, there are 2^ndims grid values that contribute to each observation point, and as such, that is the theoretical floor for performance scaling. That said, depending on the implementation, the constant term can vary by more than an order of magnitude.
| Method | RAM | Interp. Cost (Best Case) | Interp. Cost (Worst Case) | Extrap. Cost (Worst Case) |
|---|---|---|---|---|
| multilinear::regular | O(ndims) | O(2^ndims) | O(2^ndims) | O(2ndims + ndims2) |
| multilinear::rectilinear | O(ndims) | O(2^ndims) | O(2^ndims + ndims * log2(gridsize)) | O(2ndims + ndims2 + ndims * log2(gridsize)) |
Example: Multilinear w/ Regular Grid
use regular;
// Define a grid
let x = ;
let y = ;
// Grid input for rectilinear method
let grids = &;
// Grid input for regular grid method
let dims = ;
let starts = ;
let steps = ;
// Values at grid points
let z = ;
// Observation points to interpolate/extrapolate
let xobs = ;
let yobs = ;
let obs = ;
// Storage for output
let mut out = ;
// Do interpolation
interpn.unwrap;
Example: Multilinear w/ Rectilinear Grid
use rectilinear;
// Define a grid
let x = ;
let y = ;
// Grid input for rectilinear method
let grids = &;
// Values at grid points
let z = ;
// Points to interpolate/extrapolate
let xobs = ;
let yobs = ;
let obs = ;
// Storage for output
let mut out = ;
// Do interpolation
interpn.unwrap;
Development Roadmap
- Limited-memory multi-cubic interpolation/extrapolation
- Vectorized multilinear interpolation/extrapolation (with less strict memory limits)
- Vectorized multi-cubic interpolation/extrapolation (with less strict memory limits)
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.