pub struct Interp2D<Sd, Sx, Sy, D, Strat>where
    Sd: Data,
    Sd::Elem: Num + PartialOrd + NumCast + Copy + Debug + Sub,
    Sx: Data<Elem = Sd::Elem>,
    Sy: Data<Elem = Sd::Elem>,
    D: Dimension,{ /* private fields */ }
Expand description

Two dimensional interpolator

Implementations§

source§

impl<Sd, D> Interp2D<Sd, OwnedRepr<Sd::Elem>, OwnedRepr<Sd::Elem>, D, Biliniar>where Sd: Data, Sd::Elem: Num + PartialOrd + NumCast + Copy + Debug + Sub, D: Dimension,

source

pub fn builder( data: ArrayBase<Sd, D> ) -> Interp2DBuilder<Sd, OwnedRepr<Sd::Elem>, OwnedRepr<Sd::Elem>, D, Biliniar>

source§

impl<Sd, Sx, Sy, Strat> Interp2D<Sd, Sx, Sy, Ix2, Strat>where Sd: Data, Sd::Elem: Num + PartialOrd + NumCast + Copy + Debug + Sub, Sx: Data<Elem = Sd::Elem>, Sy: Data<Elem = Sd::Elem>, Strat: Interp2DStrategy<Sd, Sx, Sy, Ix2>,

source

pub fn interp_scalar( &self, x: Sx::Elem, y: Sy::Elem ) -> Result<Sd::Elem, InterpolateError>

convinient interpolation function for interpolation at one point when the data dimension is Ix2

let data = array![
    [1.0, 2.0],
    [3.0, 4.0],
];
let (qx, qy) = (0.0, 0.5);
let expected = 1.5;

let interpolator = Interp2D::builder(data).build().unwrap();
let result = interpolator.interp_scalar(qx, qy).unwrap();
source§

impl<Sd, Sx, Sy, D, Strat> Interp2D<Sd, Sx, Sy, D, Strat>where Sd: Data, Sd::Elem: Num + PartialOrd + NumCast + Copy + Debug + Sub, Sx: Data<Elem = Sd::Elem>, Sy: Data<Elem = Sd::Elem>, D: Dimension + RemoveAxis, D::Smaller: RemoveAxis, Strat: Interp2DStrategy<Sd, Sx, Sy, D>,

source

pub fn new_unchecked( x: ArrayBase<Sx, Ix1>, y: ArrayBase<Sy, Ix1>, data: ArrayBase<Sd, D>, strategy: Strat ) -> Self

Create a interpolator without any data validation. This is fast and cheap.

Safety

The following data properties are assumed, but not checked:

  • x and y are stricktly monotonic rising
  • data.shape()[0] == x.len(), data.shape()[1] == y.len()
  • the strategy is porperly initialized with the data
source

pub fn interp( &self, x: Sx::Elem, y: Sy::Elem ) -> Result<Array<Sd::Elem, <D::Smaller as Dimension>::Smaller>, InterpolateError>

Calculate the interpolated values at (x, y). Returns the interpolated data in an array two dimensions smaller than the data dimension.

Concider using interp_scalar(x, y) when the data dimension is Ix2

source

pub fn interp_array<Sqx, Sqy, Dq>( &self, xs: &ArrayBase<Sqx, Dq>, ys: &ArrayBase<Sqy, Dq> ) -> Result<Array<Sd::Elem, <Dq as DimAdd<<D::Smaller as Dimension>::Smaller>>::Output>, InterpolateError>where Sqx: Data<Elem = Sd::Elem>, Sqy: Data<Elem = Sy::Elem>, Dq: Dimension + DimAdd<<D::Smaller as Dimension>::Smaller>,

Calculate the interpolated values at all points in (xs, ys)

Dimensions

given the data dimension N and the query dimension M the return array will have the dimension M + N - 2 where the fist M dimensions correspond to the query dimenions of xs and ys

Lets assume we hava a data dimension of N = (2, 3, 4, 5) and query this data with an array of dimension M = (10), the return dimension will be (10, 4, 5) given a multi dimensional qurey of M = (10, 20) the return will be (10, 20, 4, 5)

panics

when xs.shape() != ys.shape()

source

pub fn index_point( &self, x_idx: usize, y_idx: usize ) -> (Sx::Elem, Sx::Elem, ArrayView<'_, Sd::Elem, <D::Smaller as Dimension>::Smaller>)

get (x, y, data) coordinate at the given index

panics

when index out of bounds

source

pub fn get_index_left_of(&self, x: Sx::Elem, y: Sy::Elem) -> (usize, usize)

The index of a known value left of, or at x and y.

This will never return the right most index, so calling index_point(x_idx+1, y_idx+1) is always safe.

source

pub fn is_in_x_range(&self, x: Sx::Elem) -> bool

source

pub fn is_in_y_range(&self, y: Sy::Elem) -> bool

Trait Implementations§

source§

impl<Sd, Sx, Sy, D, Strat: Debug> Debug for Interp2D<Sd, Sx, Sy, D, Strat>where Sd: Data + Debug, Sd::Elem: Num + PartialOrd + NumCast + Copy + Debug + Sub, Sx: Data<Elem = Sd::Elem> + Debug, Sy: Data<Elem = Sd::Elem> + Debug, D: Dimension + Debug,

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Sd, Sx, Sy, D, Strat> RefUnwindSafe for Interp2D<Sd, Sx, Sy, D, Strat>where D: RefUnwindSafe, Sd: RefUnwindSafe, Strat: RefUnwindSafe, Sx: RefUnwindSafe, Sy: RefUnwindSafe, <Sd as RawData>::Elem: RefUnwindSafe,

§

impl<Sd, Sx, Sy, D, Strat> Send for Interp2D<Sd, Sx, Sy, D, Strat>where Sd: Send, Strat: Send, Sx: Send, Sy: Send,

§

impl<Sd, Sx, Sy, D, Strat> Sync for Interp2D<Sd, Sx, Sy, D, Strat>where Sd: Sync, Strat: Sync, Sx: Sync, Sy: Sync,

§

impl<Sd, Sx, Sy, D, Strat> Unpin for Interp2D<Sd, Sx, Sy, D, Strat>where D: Unpin, Sd: Unpin, Strat: Unpin, Sx: Unpin, Sy: Unpin,

§

impl<Sd, Sx, Sy, D, Strat> UnwindSafe for Interp2D<Sd, Sx, Sy, D, Strat>where D: UnwindSafe, Sd: UnwindSafe, Strat: UnwindSafe, Sx: UnwindSafe, Sy: UnwindSafe, <Sd as RawData>::Elem: RefUnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.