[][src]Function piecewise_linear::points_of_inflection_iter

pub fn points_of_inflection_iter<'a, T: CoordinateType + 'a>(
    funcs: &'a [PiecewiseLinearFunction<T>]
) -> Option<PointsOfInflectionIterator<'a, T>>

Returns an iterator over pairs (x, values), where x is the union of all points of inflection of self and other, and values is a vector of the values of all passed functions, in the same order, at the corresponding x.

Example

use std::convert::TryFrom;
use piecewise_linear::{PiecewiseLinearFunction, points_of_inflection_iter};
let f = PiecewiseLinearFunction::try_from(vec![(0., 0.), (1., 1.), (2., 1.5)]).unwrap();
let g = PiecewiseLinearFunction::try_from(vec![(0., 0.), (1.5, 3.), (2., 10.)]).unwrap();
assert_eq!(
    points_of_inflection_iter(vec![f, g].as_slice()).unwrap().collect::<Vec<_>>(),
    vec![(0., vec![0., 0.]), (1., vec![1., 2.]), (1.5, vec![1.25, 3.]), (2., vec![1.5, 10.])]
);

Complexity

The complexity of this method is O(k log(k) n), where k is the number of functions passed, and n is the number of points in each function.