Function dot_product

Source
pub fn dot_product(a: &[f32], b: &[f32]) -> f32
Expand description

Computes the dot product of two vectors a and b.

§Arguments

  • a - The first vector.
  • b - The second vector.

§Returns

The dot product of a and b.

§Examples

let a = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0];
let b = [10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0];
let dot = intspan::dot_product(&a, &b);
assert_eq!(dot, 220.0);