Skip to main content

add_num_vec

Function add_num_vec 

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

§add_num_vec(x, y)

Operation Function

The add_num_vec function adds a float x to each element in a slice y of floats, returning a new vector containing the sums.

§Examples

use mathlab::math::{add, add_num_vec, fround_vec};
assert_eq!(add(0.1, 0.2), 0.30000000000000004);
assert_eq!(add(0.1, 0.2) as f32, 0.3);
assert_eq!(add_num_vec(0.1, &[0.0, 0.1, 0.2]), [0.1, 0.2, 0.30000000000000004]);
assert_eq!(fround_vec(&add_num_vec(0.1, &[0.0, 0.1, 0.2])), [0.1, 0.2, 0.3]);

End Fun Doc