[−][src]Function rusty_fitpack::splev_uniform
pub fn splev_uniform(t: &Vec<f64>, c: &Vec<f64>, k: usize, x: f64) -> f64
The function splev_uniform
evaluates a single point $x$ of
a spline $s(x)$ of degree $k$, given in its B-spline representation. The functions
assumes that the knots t
are spaced uniformly so that the interval $t_i <= x < t_(i+1)$
can be found without iterating over all knots
This function was originally written in Fortran90 by Alexander Humeniuk (Author of DFTBaby) as a modified subroutine of the splev subroutine by Paul Dierckx.
Example
Simple example of spline interpolation and evaluation
use rusty_fitpack::{splrep, splev, splev_uniform}; let x = vec![0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]; let y = vec![0.0, 1.0, 4.0, 9.0, 16.0, 25.0, 36.0, 49.0, 64.0]; let (t, c, k) = splrep(x, y, None, None, None, None, None, None, None, None, None, None); // the points where we want to evaluate the spline let x_evaluate: Vec<f64> = vec![1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0]; let mut y_from_spline: Vec<f64> = Vec::new(); for value in x_evaluate.iter() { y_from_spline.push(splev_uniform(&t, &c, k, *value)); }
Arguments:
t
: position of the knots.
c
: b-spline coefficients.
k
: the degree of $s(x)$.
x
: point where $s(x)$ must be evaluated.
Output:
y
: the value of s(x) at the point x.