[][src]Function uniform_cubic_splines::spline_inverse

pub fn spline_inverse<B, T>(y: T, knots: &[T]) -> Option<T> where
    B: Basis<T>,
    T: AsPrimitive<usize> + Float + FromPrimitive + PartialOrd + One + Zero

Computes the inverse of the spline() function. This returns the value x for which spline(x) would return y.

Results are undefined if the knots do not specifiy a monotonic (only increasing or only decreasing) set of values.

If no solution can be found the function returns None.

Panics

If the "unstable" feature is enabled this will panic when this is built with debug assertions and the knots are not monotonic.

Examples

use uniform_cubic_splines::{spline_inverse, basis::Linear};

let knots = [0.0, 0.0, 0.5, 0.5];

assert!(Some(0.5) == spline_inverse::<Linear, _>(0.25f64, &knots));