diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2010-02-27 11:19:14 -0500 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2010-02-27 11:19:14 -0500 |
commit | 3f393490adc2e5ca705b660ffac3465e8200ff5d (patch) | |
tree | 3a4e32e86ec921da7bd762e2255c70e9e27fc86e /Eigen/src/Core | |
parent | 15a33622acfb195935adf190508d7e9e8238c4ee (diff) |
dot: handle the rowvector.dot(colvector) case where one needs to transpose.
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r-- | Eigen/src/Core/Dot.h | 21 |
1 files 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<typename T, typename U, - bool IsSameType = ei_is_same_type<typename T::Scalar, typename U::Scalar>::ret> + bool IsSameType = ei_is_same_type<typename T::Scalar, typename U::Scalar>::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<T>::Scalar run(const MatrixBase<T>& a, const MatrixBase<U>& b) @@ -39,7 +47,16 @@ struct ei_dot_nocheck }; template<typename T, typename U> -struct ei_dot_nocheck<T, U, false> +struct ei_dot_nocheck<T, U, true, true> +{ + static inline typename ei_traits<T>::Scalar run(const MatrixBase<T>& a, const MatrixBase<U>& b) + { + return a.adjoint().cwiseProduct(b).sum(); + } +}; + +template<typename T, typename U, bool NeedToTranspose> +struct ei_dot_nocheck<T, U, false, NeedToTranspose> { static inline typename ei_traits<T>::Scalar run(const MatrixBase<T>&, const MatrixBase<U>&) { |