Struct Interp2D

Source
pub struct Interp2D<D, S>
where D: Data + RawDataClone + Clone, D::Elem: PartialEq + Debug, S: Strategy2D<D> + Clone,
{ 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>
where D: Data + RawDataClone + Clone, D::Elem: PartialEq + Debug, S: Strategy2D<D> + Clone,

Source

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>
where D: Data + RawDataClone + Clone, D::Elem: PartialOrd + Debug, S: Strategy2D<D> + Clone,

Source

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
Source

pub fn view(&self) -> Interp2DViewed<&D::Elem, S>
where S: for<'a> Strategy2D<ViewRepr<&'a D::Elem>>, D::Elem: Clone,

Return an interpolator with viewed data.

Source

pub fn into_owned(self) -> Interp2DOwned<D::Elem, S>
where S: Strategy2D<OwnedRepr<D::Elem>>, D::Elem: Clone,

Turn the interpolator into an Interp2DOwned, cloning the array elements if necessary.

Source§

impl<D> Interp2D<D, Box<dyn Strategy2D<D>>>
where D: Data + RawDataClone + Clone, D::Elem: PartialEq + Debug,

Source

pub fn set_strategy( &mut self, strategy: Box<dyn Strategy2D<D>>, ) -> Result<(), ValidateError>

Update strategy dynamically.

Source§

impl<D> Interp2D<D, Strategy2DEnum>
where D: Data + RawDataClone + Clone, D::Elem: Num + PartialOrd + Copy + Debug,

Source

pub fn set_strategy( &mut self, strategy: impl Into<Strategy2DEnum>, ) -> Result<(), ValidateError>

Update strategy dynamically.

Trait Implementations§

Source§

impl<D, S> Clone for Interp2D<D, S>
where D: Data + RawDataClone + Clone + Clone, D::Elem: PartialEq + Debug + Clone, S: Strategy2D<D> + Clone + Clone,

Source§

fn clone(&self) -> Interp2D<D, S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D, S> Debug for Interp2D<D, S>
where D: Data + RawDataClone + Clone + Debug, D::Elem: PartialEq + Debug + Debug, S: Strategy2D<D> + Clone + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D> From<Interp2D<D, Strategy2DEnum>> for InterpolatorEnum<D>
where D: Data + RawDataClone + Clone, D::Elem: Num + PartialOrd + Copy + Debug,

Source§

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,

Source§

fn ndim(&self) -> usize

Returns 2.

Source§

fn validate(&mut self) -> Result<(), ValidateError>

Validate interpolator data.
Source§

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>

Set Extrapolate variant, checking validity.
Source§

impl<D, S> PartialEq for Interp2D<D, S>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<D, S> Freeze for Interp2D<D, S>
where S: Freeze, <D as RawData>::Elem: Freeze, D: Freeze,

§

impl<D, S> RefUnwindSafe for Interp2D<D, S>

§

impl<D, S> Send for Interp2D<D, S>
where S: Send, <D as RawData>::Elem: Send, D: Send,

§

impl<D, S> Sync for Interp2D<D, S>
where S: Sync, <D as RawData>::Elem: Sync, D: Sync,

§

impl<D, S> Unpin for Interp2D<D, S>
where S: Unpin, <D as RawData>::Elem: Unpin, D: Unpin,

§

impl<D, S> UnwindSafe for Interp2D<D, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.