Interp1D

Struct Interp1D 

Source
pub struct Interp1D<C, Z> { /* private fields */ }
Expand description
  • C: Coordinate type.
  • Z: Value type.

Implementations§

Source§

impl<C, Z> Interp1D<C, Z>

Source

pub fn new(x: Vec<C>, z: Vec<Z>) -> Self
where C: PartialOrd,

Create a new interpolation engine.

Interpolates values which are sampled on a rectangular grid.

§Parameters
  • x: The x-coordinates. Must be monotonic.
  • z: The values z(x) for each grid point defined by the x coordinates.
§Panics

Panics when

  • dimensions of the indices and z-values don’t match.
  • one axis is empty.
  • x values are not monotonic.
Source

pub fn bounds(&self) -> (C, C)
where C: Copy,

Get the boundaries of the sample range as (x0, x1) tuple.

Source

pub fn is_within_bounds(&self, x: C) -> bool
where C: PartialOrd + Copy,

Check if the x coordinate lies within the defined sample range.

Source

pub fn xs(&self) -> &Vec<C>

Get the x-coordinate values.

Source

pub fn z(&self) -> &Vec<Z>

Get the raw z values.

Source

pub fn map_values<Z2>(&self, f: impl Fn(&Z) -> Z2) -> Interp1D<C, Z2>
where C: PartialOrd + Clone,

Create a new interpolated table by applying a function elementwise to the values.

Source

pub fn map_axis<Xnew>(self, f: impl Fn(C) -> Xnew) -> Interp1D<Xnew, Z>
where Xnew: PartialOrd,

Apply a function to the coordinates values of the axis. Panics if the new coordinates are not monotonically increasing.

Source§

impl<C, Z> Interp1D<C, Z>
where C: Copy + Sub<Output = C> + Div + PartialOrd, Z: Copy + Mul<<C as Div>::Output, Output = Z> + Add<Output = Z> + Sub<Output = Z>, <C as Div>::Output: Copy + Add<Output = <C as Div>::Output> + Sub<Output = <C as Div>::Output>,

Source

pub fn eval(&self, x: C) -> Z

Evaluate the sampled function by interpolation at x.

If x lies out of the sampled range then the function is silently extrapolated. The boundaries of the sample range can be queried with bounds().

Source

pub fn eval_no_extrapolation(&self, x: C) -> Option<Z>

Returns the same value as eval() as long as x is within the range of the samples. Otherwise None is returned instead of an extrapolation.

Trait Implementations§

Source§

impl<C: Clone, Z: Clone> Clone for Interp1D<C, Z>

Source§

fn clone(&self) -> Interp1D<C, Z>

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<C: Debug, Z: Debug> Debug for Interp1D<C, Z>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C, Z> Freeze for Interp1D<C, Z>

§

impl<C, Z> RefUnwindSafe for Interp1D<C, Z>

§

impl<C, Z> Send for Interp1D<C, Z>
where C: Send, Z: Send,

§

impl<C, Z> Sync for Interp1D<C, Z>
where C: Sync, Z: Sync,

§

impl<C, Z> Unpin for Interp1D<C, Z>
where C: Unpin, Z: Unpin,

§

impl<C, Z> UnwindSafe for Interp1D<C, Z>
where C: UnwindSafe, Z: UnwindSafe,

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> 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> 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.