pub struct Interp2D<D, S>{
pub data: InterpData2D<D>,
pub strategy: S,
pub extrapolate: Extrapolate<D::Elem>,
}
Expand description
2-D interpolator
Fields§
§data: InterpData2D<D>
Interpolator data.
strategy: S
Interpolation strategy.
extrapolate: Extrapolate<D::Elem>
Extrapolation setting.
Implementations§
Source§impl<D, S> Interp2D<D, S>
impl<D, S> Interp2D<D, S>
Sourcepub fn check_extrapolate(
&self,
extrapolate: &Extrapolate<D::Elem>,
) -> Result<(), ValidateError>
pub fn check_extrapolate( &self, extrapolate: &Extrapolate<D::Elem>, ) -> Result<(), ValidateError>
Check applicability of strategy, data, and extrapolate setting.
Source§impl<D, S> Interp2D<D, S>
impl<D, S> Interp2D<D, S>
Sourcepub fn new(
x: ArrayBase<D, Ix1>,
y: ArrayBase<D, Ix1>,
f_xy: ArrayBase<D, Ix2>,
strategy: S,
extrapolate: Extrapolate<D::Elem>,
) -> Result<Self, ValidateError>
pub fn new( x: ArrayBase<D, Ix1>, y: ArrayBase<D, Ix1>, f_xy: ArrayBase<D, Ix2>, strategy: S, extrapolate: Extrapolate<D::Elem>, ) -> Result<Self, ValidateError>
Construct and validate a 2-D interpolator.
Applicable interpolation strategies:
Extrapolate::Enable
is valid for strategy::Linear
§Example:
use ndarray::prelude::*;
use ninterp::prelude::*;
// f(x, y) = 0.2 * x + 0.4 * y
// type annotation for clarity
let interp: Interp2DOwned<f64, _> = Interp2D::new(
// x
array![0., 1., 2.], // x0, x1, x2
// y
array![0., 1., 2., 3.], // y0, y1, y2
// f(x, y)
array![
[0.0, 0.4, 0.8, 1.2], // f(x0, y0), f(x0, y1), f(x0, y2), f(x0, y3)
[0.2, 0.6, 1.0, 1.4], // f(x1, y0), f(x1, y1), f(x1, y2), f(x1, y3)
[0.4, 0.8, 1.2, 1.6], // f(x2, y0), f(x2, y1), f(x2, y2), f(x2, y3)
],
strategy::Linear, // strategy mod is exposed via `use ndarray::prelude::*;`
Extrapolate::Clamp, // restrict point within grid bounds
)
.unwrap();
assert_eq!(interp.interpolate(&[1.5, 1.5]).unwrap(), 0.9);
assert_eq!(
interp.interpolate(&[-1., 3.5]).unwrap(),
interp.interpolate(&[0., 3.]).unwrap()
); // point is restricted to within grid bounds
Sourcepub fn view(&self) -> Interp2DViewed<&D::Elem, S>
pub fn view(&self) -> Interp2DViewed<&D::Elem, S>
Return an interpolator with viewed data.
Sourcepub fn into_owned(self) -> Interp2DOwned<D::Elem, S>
pub fn into_owned(self) -> Interp2DOwned<D::Elem, S>
Turn the interpolator into an Interp2DOwned
, cloning the array elements if necessary.
Source§impl<D> Interp2D<D, Box<dyn Strategy2D<D>>>
impl<D> Interp2D<D, Box<dyn Strategy2D<D>>>
Sourcepub fn set_strategy(
&mut self,
strategy: Box<dyn Strategy2D<D>>,
) -> Result<(), ValidateError>
pub fn set_strategy( &mut self, strategy: Box<dyn Strategy2D<D>>, ) -> Result<(), ValidateError>
Update strategy dynamically.
Source§impl<D> Interp2D<D, Strategy2DEnum>
impl<D> Interp2D<D, Strategy2DEnum>
Sourcepub fn set_strategy(
&mut self,
strategy: impl Into<Strategy2DEnum>,
) -> Result<(), ValidateError>
pub fn set_strategy( &mut self, strategy: impl Into<Strategy2DEnum>, ) -> Result<(), ValidateError>
Update strategy dynamically.
Trait Implementations§
Source§impl<D> From<Interp2D<D, Strategy2DEnum>> for InterpolatorEnum<D>
impl<D> From<Interp2D<D, Strategy2DEnum>> for InterpolatorEnum<D>
Source§fn from(interpolator: Interp2D<D, Strategy2DEnum>) -> Self
fn from(interpolator: Interp2D<D, Strategy2DEnum>) -> Self
Converts to this type from the input type.
Source§impl<D, S> Interpolator<<D as RawData>::Elem> for Interp2D<D, S>where
D: Data + RawDataClone + Clone,
D::Elem: Num + Euclid + PartialOrd + Debug + Copy,
S: Strategy2D<D> + Clone,
impl<D, S> Interpolator<<D as RawData>::Elem> for Interp2D<D, S>where
D: Data + RawDataClone + Clone,
D::Elem: Num + Euclid + PartialOrd + Debug + Copy,
S: Strategy2D<D> + Clone,
Source§fn interpolate(&self, point: &[D::Elem]) -> Result<D::Elem, InterpolateError>
fn interpolate(&self, point: &[D::Elem]) -> Result<D::Elem, InterpolateError>
Interpolate at supplied point.
Source§fn set_extrapolate(
&mut self,
extrapolate: Extrapolate<D::Elem>,
) -> Result<(), ValidateError>
fn set_extrapolate( &mut self, extrapolate: Extrapolate<D::Elem>, ) -> Result<(), ValidateError>
Set
Extrapolate
variant, checking validity.Source§impl<D, S> PartialEq for Interp2D<D, S>where
D: Data + RawDataClone + Clone,
D::Elem: PartialEq + Debug,
S: Strategy2D<D> + Clone + PartialEq,
InterpData2D<D>: PartialEq,
impl<D, S> PartialEq for Interp2D<D, S>where
D: Data + RawDataClone + Clone,
D::Elem: PartialEq + Debug,
S: Strategy2D<D> + Clone + PartialEq,
InterpData2D<D>: PartialEq,
Auto Trait Implementations§
impl<D, S> Freeze for Interp2D<D, S>
impl<D, S> RefUnwindSafe for Interp2D<D, S>
impl<D, S> Send for Interp2D<D, S>
impl<D, S> Sync for Interp2D<D, S>
impl<D, S> Unpin for Interp2D<D, S>
impl<D, S> UnwindSafe for Interp2D<D, S>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more