vector_space/dot.rs
1use crate::VectorSpace;
2
3/// This trait defines the dot product.
4pub trait DotProduct<T = Self>: VectorSpace {
5 /// The output type of the dot product.
6 type Output;
7
8 /// The dot product.
9 fn dot(self, other: T) -> <Self as DotProduct<T>>::Output;
10}
11
12impl DotProduct for f32 {
13 type Output = f32;
14 fn dot(self, other: Self) -> f32 {
15 self * other
16 }
17}
18impl DotProduct for f64 {
19 type Output = f64;
20 fn dot(self, other: Self) -> f64 {
21 self * other
22 }
23}