Skip to main content

subt_vec_num

Function subt_vec_num 

Source
pub fn subt_vec_num(x: &[f64], y: f64) -> Vec<f64>
Expand description

§subt_vec_num(x, y)

Operation Function

The subt_vec_num subtracts a given float y from every element in a slice x of floats, returning a new vector containing the differences.

§Examples

use mathlab::math::{subt, subt_vec_num, fround_vec};
assert_eq!(subt(0.1, 0.2), -0.1);
assert_eq!(subt(0.1, 0.2) as f32, -0.1);
assert_eq!(subt_vec_num(&[0.0, 0.1, 0.2, 0.3], 0.3), [-0.3, -0.19999999999999998, -0.09999999999999998, 0.0]);
assert_eq!(fround_vec(&subt_vec_num(&[0.0, 0.1, 0.2, 0.3], 0.3)), [-0.3, -0.2, -0.1, 0.0]);

End Fun Doc