use std::ops::{Mul, Add};
use num_traits::Zero;
use crate::Vector;
pub trait Dot<Rhs: Vector>: Vector
{
type Output;
fn dot(self, rhs: Rhs) -> Self::Output;
}
impl<F, const L: usize> Dot<[F; L]> for [F; L]
where
Self: Vector,
F: Mul<F, Output = F> + Add<F, Output = F> + Zero + Clone
{
type Output = F;
fn dot(self, rhs: [F; L]) -> Self::Output
{
(0..L).map(|i| self[i].clone()*rhs[i].clone()).reduce(|a, b| a + b).unwrap_or(F::zero())
}
}