Function sum

Source
pub fn sum(a: &[f32]) -> f32
Expand description

Computes the sum of all elements in a vector a.

§Arguments

  • a - The vector.

§Returns

The sum of all elements in a.

§Examples

let a = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0];
let sum_value = nwr::sum(&a);
assert_eq!(sum_value, 55.0);