From 226b115f1e0b168ae4d9fa9685cefb772c35d738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Thu, 6 Nov 2014 23:17:35 +0100 Subject: [PATCH] Overload `DVec * DVec -> DVec` and `DVec / Dvec -> DVec`. Fix #31. --- src/structs/dvec_macros.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/structs/dvec_macros.rs b/src/structs/dvec_macros.rs index a33b64c7..92b745f1 100644 --- a/src/structs/dvec_macros.rs +++ b/src/structs/dvec_macros.rs @@ -186,6 +186,22 @@ macro_rules! dvec_impl( } } + impl + Zero> $mul> for $dvec { + #[inline] + fn binop(left: &$dvec, right: &$dvec) -> $dvec { + assert!(left.len() == right.len()); + FromIterator::from_iter(left.as_slice().iter().zip(right.as_slice().iter()).map(|(a, b)| *a * *b)) + } + } + + impl + Zero> $div> for $dvec { + #[inline] + fn binop(left: &$dvec, right: &$dvec) -> $dvec { + assert!(left.len() == right.len()); + FromIterator::from_iter(left.as_slice().iter().zip(right.as_slice().iter()).map(|(a, b)| *a / *b)) + } + } + impl + Zero> $add> for $dvec { #[inline] fn binop(left: &$dvec, right: &$dvec) -> $dvec {