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

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.

The underlying algorithm uses the regular falsi method to find the solution.

The iterations parameter controls the max. number of iterations of this this algorithm. If omitted, the default is 32.

The precision parameter controls the cutoff precision that is used to determine when the result is a good enough approximation, even if the specified number of iterations was not reached yet. If omitted, the default is 1e-6.

Panics

If the monotonic_check feature is enabled this will panic if the knots slice is not monotonic.

Examples

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

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

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