use interp1d::Interp1d; #[test] fn test_simple() { // Data (already sorted) let x: Vec = vec![1.0, 2.0, 3.0]; let y: Vec = vec![5.0, 3.0, 4.0]; // Using `new_sorted` since data is already sorted let interpolator = Interp1d::new_sorted(x, y).unwrap(); // Points at which we wish to interpolate let x_interp = vec![1.5, 2.5]; // Intepolate with checked fn let y_interp: Vec = x_interp .iter() .map(|&x| interpolator.interpolate_checked(x)) .collect::, _>>() .unwrap(); // all points are in the domain in this example assert_eq!(y_interp, vec![4.0, 3.5]); }