Interpolation

Trait Interpolation 

Source
pub trait Interpolation<T>
where T: Num,
{ // Required methods fn eval( &self, xa: &[T], ya: &[T], x: T, acc: &mut Accelerator, ) -> Result<T, DomainError>; fn eval_deriv( &self, xa: &[T], ya: &[T], x: T, acc: &mut Accelerator, ) -> Result<T, DomainError>; fn eval_deriv2( &self, xa: &[T], ya: &[T], x: T, acc: &mut Accelerator, ) -> Result<T, DomainError>; fn eval_integ( &self, xa: &[T], ya: &[T], a: T, b: T, acc: &mut Accelerator, ) -> Result<T, DomainError>; }
Expand description

Defines the required evaluation methods.

Required Methods§

Source

fn eval( &self, xa: &[T], ya: &[T], x: T, acc: &mut Accelerator, ) -> Result<T, DomainError>

Returns the interpolated value y for a given point x, using the data arrays xa and ya and the Accelerator acc.

§Example
let xa = [0.0, 1.0, 2.0];
let ya = [0.0, 2.0, 4.0];
let interp = Cubic.build(&xa, &ya)?;
let mut acc = Accelerator::new();

let y = interp.eval(&xa, &ya, 1.5, &mut acc)?;

assert_eq!(y, 3.0);
§Errors

Returns a DomainError if x is outside the range of xa.

Source

fn eval_deriv( &self, xa: &[T], ya: &[T], x: T, acc: &mut Accelerator, ) -> Result<T, DomainError>

Returns the derivative dy/dx of an interpolated function for a given point x, using the data arrays xa and ya and the Accelerator acc.

§Example
let xa = [0.0, 1.0, 2.0];
let ya = [0.0, 2.0, 4.0];
let interp = Cubic.build(&xa, &ya)?;
let mut acc = Accelerator::new();

let dydx = interp.eval_deriv(&xa, &ya, 1.5, &mut acc)?;

assert_eq!(dydx, 2.0);
§Errors

Returns a DomainError if x is outside the range of xa.

Source

fn eval_deriv2( &self, xa: &[T], ya: &[T], x: T, acc: &mut Accelerator, ) -> Result<T, DomainError>

Returns the second derivative d²y/dx² of an interpolated function for a given point x, using the data arrays xa and ya and the Accelerator acc.

§Example
let xa = [0.0, 1.0, 2.0];
let ya = [0.0, 2.0, 4.0];
let interp = Cubic.build(&xa, &ya)?;
let mut acc = Accelerator::new();

let dydx2 = interp.eval_deriv2(&xa, &ya, 1.5, &mut acc)?;

assert_eq!(dydx2, 0.0);
§Errors

Returns a DomainError if x is outside the range of xa.

Source

fn eval_integ( &self, xa: &[T], ya: &[T], a: T, b: T, acc: &mut Accelerator, ) -> Result<T, DomainError>

Returns the numerical integral of an interpolated function over the range [a ,b], using the data arrays xa and ya and the Accelerator acc.

§Example
let xa = [0.0, 1.0, 2.0];
let ya = [0.0, 2.0, 4.0];
let interp = Cubic.build(&xa, &ya)?;
let mut acc = Accelerator::new();

let int = interp.eval_integ(&xa, &ya, 0.0, 2.0, &mut acc)?;

assert_eq!(int, 4.0);
§Errors

Returns a DomainError if a or b is outside the range of xa.

Implementors§

Source§

impl<T> Interpolation<T> for AkimaInterp<T>
where T: Num,

Source§

impl<T> Interpolation<T> for AkimaPeriodicInterp<T>
where T: Num,

Source§

impl<T> Interpolation<T> for CubicInterp<T>
where T: Num + Lapack,

Source§

impl<T> Interpolation<T> for CubicPeriodicInterp<T>
where T: Num + Lapack,

Source§

impl<T> Interpolation<T> for LinearInterp<T>
where T: Num,

Source§

impl<T> Interpolation<T> for SteffenInterp<T>
where T: Num,