|
1 | 1 | //! The `ninterp` crate provides |
2 | 2 | //! [multivariate interpolation](https://en.wikipedia.org/wiki/Multivariate_interpolation#Regular_grid) |
3 | 3 | //! over rectilinear grids of any dimensionality. |
4 | | -//! A variety of interpolation strategies are implemented, however more are likely to be added. |
5 | | -//! Linear extrapolation is implemented for all dimensionalities. |
| 4 | +//! A variety of interpolation strategies are implemented, and more are likely to be added. |
6 | 5 | //! |
7 | 6 | //! There are hard-coded interpolators for lower dimensionalities (up to N = 3) for better runtime performance. |
8 | 7 | //! |
9 | | -//! All interpolation is handled through instances of the [`Interpolator`] enum, |
10 | | -//! with the selected tuple variant containing relevant data. |
11 | | -//! Interpolation is executed by calling [`Interpolator::interpolate`]. |
12 | | -//! |
13 | 8 | //! # Feature Flags |
14 | 9 | //! - `serde`: support for [`serde`](https://crates.io/crates/serde) |
15 | 10 | //! |
16 | 11 | //! # Getting Started |
17 | 12 | //! A prelude module has been defined: `use ninterp::prelude::*;`. |
18 | | -//! This exposes the types necessary for usage: [`Interpolator`], [`Strategy`], [`Extrapolate`], and the trait [`InterpMethods`]. |
| 13 | +//! This exposes the types necessary for usage: [`Interpolator`], [`Strategy`], and [`Extrapolate`]. |
19 | 14 | //! |
20 | 15 | //! All interpolation is handled through instances of the [`Interpolator`] enum. |
21 | 16 | //! |
22 | 17 | //! Interpolation is executed by calling [`Interpolator::interpolate`]. |
23 | 18 | //! The length of the supplied point slice must be equal to the interpolator dimensionality. |
24 | | -//! The interpolator dimensionality can be retrieved by calling [`Interpolator::ndim`]. |
25 | 19 | //! |
26 | 20 | //! ## Note |
27 | 21 | //! For interpolators of dimensionality N ≥ 1: |
|
30 | 24 | //! - To set or get field values, use the corresponding named methods (`x`, `set_x`, etc.). |
31 | 25 | //! - An interpolation [`Strategy`] (e.g. linear, left-nearest, etc.) must be specified. |
32 | 26 | //! Not all interpolation strategies are implemented for every dimensionality. |
33 | | -//! [`Strategy::Linear`] is implemented for all dimensionalities. |
| 27 | +//! [`Strategy::Linear`] and [`Strategy::Nearest`] are implemented for all dimensionalities. |
34 | 28 | //! - An [`Extrapolate`] setting must be specified. |
35 | 29 | //! This controls what happens when a point is beyond the range of supplied coordinates. |
36 | 30 | //! If you are unsure which variant to choose, [`Extrapolate::Error`] is likely what you want. |
| 31 | +//! Linear extrapolation is implemented for all dimensionalities. |
37 | 32 | //! |
38 | 33 | //! For 0-D (constant-value) interpolators, instantiate directly, e.g. `Interpolator::Interp0D(0.5)` |
39 | 34 | //! |
@@ -146,7 +141,7 @@ impl Interpolator { |
146 | 141 | /// - [`Strategy::Nearest`] |
147 | 142 | /// |
148 | 143 | /// Applicable extrapolation strategies: |
149 | | - /// - [`Extrapolate::Enable`] (for [`Strategy::Linear`]) |
| 144 | + /// - [`Extrapolate::Enable`] (in combination with [`Strategy::Linear`]) |
150 | 145 | /// - [`Extrapolate::Clamp`] |
151 | 146 | /// - [`Extrapolate::Error`] |
152 | 147 | /// |
@@ -198,7 +193,7 @@ impl Interpolator { |
198 | 193 | /// - [`Strategy::Nearest`] |
199 | 194 | /// |
200 | 195 | /// Applicable extrapolation strategies: |
201 | | - /// - [`Extrapolate::Enable`] (for [`Strategy::Linear`]) |
| 196 | + /// - [`Extrapolate::Enable`] (in combination with [`Strategy::Linear`]) |
202 | 197 | /// - [`Extrapolate::Clamp`] |
203 | 198 | /// - [`Extrapolate::Error`] |
204 | 199 | /// |
@@ -252,7 +247,7 @@ impl Interpolator { |
252 | 247 | /// - [`Strategy::Nearest`] |
253 | 248 | /// |
254 | 249 | /// Applicable extrapolation strategies: |
255 | | - /// - [`Extrapolate::Enable`] (for [`Strategy::Linear`]) |
| 250 | + /// - [`Extrapolate::Enable`] (in combination with [`Strategy::Linear`]) |
256 | 251 | /// - [`Extrapolate::Clamp`] |
257 | 252 | /// - [`Extrapolate::Error`] |
258 | 253 | /// |
@@ -316,7 +311,7 @@ impl Interpolator { |
316 | 311 | /// - [`Strategy::Nearest`] |
317 | 312 | /// |
318 | 313 | /// Applicable extrapolation strategies: |
319 | | - /// - [`Extrapolate::Enable`] (for [`Strategy::Linear`]) |
| 314 | + /// - [`Extrapolate::Enable`] (in combination with [`Strategy::Linear`]) |
320 | 315 | /// - [`Extrapolate::Clamp`] |
321 | 316 | /// - [`Extrapolate::Error`] |
322 | 317 | /// |
@@ -803,9 +798,7 @@ pub enum Strategy { |
803 | 798 | #[derive(Clone, Debug, PartialEq, Default)] |
804 | 799 | #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] |
805 | 800 | pub enum Extrapolate { |
806 | | - /// If interpolant point is beyond the limits of the interpolation grid, |
807 | | - /// find result via extrapolation using slope of nearby points. |
808 | | - /// Currently only implemented for 1-D linear interpolation. |
| 801 | + /// Evaluate beyond the limits of the interpolation grid. |
809 | 802 | Enable, |
810 | 803 | /// Restrict interpolant point to the limits of the interpolation grid, using [`f64::clamp`]. |
811 | 804 | Clamp, |
|
0 commit comments