interp1d: A simple, lightweight interpolation library written in Rust
This library is intended to be very simple and lightweight. The core Interp1D struct takes some set of (x, y) pairs and has a simple linear interpolation method. Unlike other libaries I found, this libary is unique in two cores ways:
- It takes ownership over the
(x, y)pairs and internally sorts them, using a binary search to find the two neighbors with which interpolation is done. This prevents the sorting/searching that other functionsfn(&[T], &[T], T) -> Tmay do. - It allows for the types of
xandyto differ.xcould be an integer or a float and can be of a different type thany(ymust still be a float). This allows for e.g. interpolation on a 1D lattice.
Simple Usage
An example with double precision floats:
use Interp1d;
An example with x as usize:
use Interp1d;