A lightweight library for interpolating on a regular / rectilinear multidimensional grid.
This library revolves around the struct GriddedData, which stores data values on a regular /
rectilinear grid of arbitrary dimensions. This data can then be used for multivariate interpolation.
Currently, the following algorithms are available:
- Nearest-neighbor interpolation
- n-linear interpolation
If more algorithms are needed, please do not hesistate to open an issue on the repository website: https://github.com/StefanMathis/gridded_data
use GriddedData;
/*
1-dimensional example:
The underlying function is known to have the following data / node pairs:
node : 0 1 2 3 4
---------
data: 0 2 4 2 0
*/
let x = vec!;
let data = vec!;
let grid1 = new.unwrap;
// Access the data at the grid points
assert_eq!;
// Get values between grid points via different interpolation methods
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
/*
2-dimensional example:
The underlying function is known to have the following data / node pairs (with a node defined by both its x- and y-value):
x 0 1 2
y -------
0 | 0 1 2
1 | 3 4 5
*/
let x = vec!;
let y = vec!;
let data = vec!;
let grid2 = new.unwrap;
// Access the data at the grid points
assert_eq!;
// Get values between grid points via different interpolation methods
assert_eq!;
assert_eq!;
Serialization and deserialization
GriddedData can be serialized and deserialized via the serde crate.
Unfortunately, it is currently not possible to implement this feature for arbitrary dimensions
due to limitations within Rust itself. Therefore, manual implementations for the dimensions
1 to 16 exist.
This functionality is gated behind the serde feature flag.
Providing data via matrix libraries
nalgebra integration
The function [from_nalgebra_matrix] allows to provide the data values
for a 2-dimensional GriddedData<2> via a nalgebra matrix.
See the function docstring for an example.
This function is gated behind the nalgebra feature flag.