aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/GeneralProduct.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2015-10-08 17:36:57 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2015-10-08 17:36:57 +0200
commit8d00a953af6d84413abd0c8941db6666f4e0bf4e (patch)
tree72676b68f0b6e094906cea3e89ac77608e5f74c3 /Eigen/src/Core/GeneralProduct.h
parentdd934ad057e5ad5a5bc9e9a2b4340b4ac16c01d3 (diff)
Fix a nesting issue in some matrix-vector cases.
Diffstat (limited to 'Eigen/src/Core/GeneralProduct.h')
-rw-r--r--Eigen/src/Core/GeneralProduct.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/Eigen/src/Core/GeneralProduct.h b/Eigen/src/Core/GeneralProduct.h
index 4a5054592..fe8204ac3 100644
--- a/Eigen/src/Core/GeneralProduct.h
+++ b/Eigen/src/Core/GeneralProduct.h
@@ -350,10 +350,11 @@ template<> struct gemv_dense_selector<OnTheRight,ColMajor,false>
template<typename Lhs, typename Rhs, typename Dest>
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
{
- // TODO makes sure dest is sequentially stored in memory, otherwise use a temp
+ // TODO if rhs is large enough it might be beneficial to make sure that dest is sequentially stored in memory, otherwise use a temp
+ typename nested_eval<Rhs,1>::type actual_rhs(rhs);
const Index size = rhs.rows();
for(Index k=0; k<size; ++k)
- dest += (alpha*rhs.coeff(k)) * lhs.col(k);
+ dest += (alpha*actual_rhs.coeff(k)) * lhs.col(k);
}
};
@@ -362,10 +363,10 @@ template<> struct gemv_dense_selector<OnTheRight,RowMajor,false>
template<typename Lhs, typename Rhs, typename Dest>
static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha)
{
- // TODO makes sure rhs is sequentially stored in memory, otherwise use a temp
+ typename nested_eval<Rhs,Lhs::RowsAtCompileTime>::type actual_rhs(rhs);
const Index rows = dest.rows();
for(Index i=0; i<rows; ++i)
- dest.coeffRef(i) += alpha * (lhs.row(i).cwiseProduct(rhs.transpose())).sum();
+ dest.coeffRef(i) += alpha * (lhs.row(i).cwiseProduct(actual_rhs.transpose())).sum();
}
};