pub fn round_vec(x: &[f64]) -> Vec<f64>
Expand description
§round_vec(x)
Rounding Function
The round_vec
function takes a slice of f64
values as input and returns
a Vec<f64>
where each element is the rounded value of the corresponding input element.
The round
function aligns a number to the closest integer,
adjusting fractions of 0.5
or greater up, and less than 0.5
down.
§Examples
use mathlab::math::{round, round_vec};
let my_x_f64_array = [0.0, 0.5, 1.01, 1.49, 1.99, -0.5, -1.01, -1.49, -1.99];
assert_eq!(round(1.49), 1.0);
assert_eq!(round(1.5), 2.0);
assert_eq!(round_vec(&my_x_f64_array), [0.0, 1.0, 1.0, 1.0, 2.0, -1.0, -1.0, -1.0, -2.0]);
End Fun Doc