Added dot product
@@ -476,7 +476,11 @@ impl VecOps for Vec<Dual> {
}
fn dot(&self, _other: &Self) -> Self::Scalar {
- unimplemented!()
+ // dot product of Dual is similar to Complex with \epsilon^2 = 0
+ self.into_iter()
+ .zip(other)
+ .map(|(x,y)| *x.value * *y.value)
+ .fold(Dual::new(0., 0.) |sum: Dual, x| sum.add(x))
}
fn norm(&self) -> Self::Scalar {
