Skip to main content

dot_product

Function dot_product 

Source
pub fn dot_product<T: Num + Copy + Add<Output = T> + Mul<Output = T>>(
    a: &[T],
    b: &[T],
) -> T
Expand description

Dot product of two slices. Returns T::zero() if either is empty. Truncates to the shorter length if they differ.

ยงExamples

use mathverse_core::ops::dot_product;

assert_eq!(dot_product(&[1.0, 2.0, 3.0], &[4.0, 5.0, 6.0]), 32.0);
assert_eq!(dot_product(&[2, 3], &[4, 5]), 23);