use common_traits::*; #[inline] pub fn dot_product(a: A, b: B) -> RT where A: Sequence, B: Sequence, A::Item: To, B::Item: To, MT: To, RT: To, { // Check compatability of the vectors assert_eq!(a.len(), b.len()); // Compute the dot product let mut accum = RT::ZERO; for (a, b) in a.iter().zip(b.iter()) { accum = (a.to()).mul_add(b.to(), accum.to()).to(); } accum } fn main() { let x: Vec = vec![1.0, 2.0, 3.0]; let w: Vec = vec![3, 2, 1]; let res: u16 = dot_product::(&x, &w); println!("{:?}", res); }