From 3f393490adc2e5ca705b660ffac3465e8200ff5d Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Sat, 27 Feb 2010 11:19:14 -0500 Subject: [PATCH] dot: handle the rowvector.dot(colvector) case where one needs to transpose. --- Eigen/src/Core/Dot.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index 72f6c571d..9acc98eba 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -29,7 +29,15 @@ // with mismatched types, the compiler emits errors about failing to instantiate cwiseProduct BEFORE // looking at the static assertions. Thus this is a trick to get better compile errors. template::ret> + bool IsSameType = ei_is_same_type::ret, +// the NeedToTranspose condition here is taken straight from Assign.h + bool NeedToTranspose = T::IsVectorAtCompileTime + && U::IsVectorAtCompileTime + && ((int(T::RowsAtCompileTime) == 1 && int(U::ColsAtCompileTime) == 1) + | // FIXME | instead of || to please GCC 4.4.0 stupid warning "suggest parentheses around &&". + // revert to || as soon as not needed anymore. + (int(T::ColsAtCompileTime) == 1 && int(U::RowsAtCompileTime) == 1)) +> struct ei_dot_nocheck { static inline typename ei_traits::Scalar run(const MatrixBase& a, const MatrixBase& b) @@ -39,7 +47,16 @@ struct ei_dot_nocheck }; template -struct ei_dot_nocheck +struct ei_dot_nocheck +{ + static inline typename ei_traits::Scalar run(const MatrixBase& a, const MatrixBase& b) + { + return a.adjoint().cwiseProduct(b).sum(); + } +}; + +template +struct ei_dot_nocheck { static inline typename ei_traits::Scalar run(const MatrixBase&, const MatrixBase&) {