From 5d1263e7c546ad6dcf6490fed8e6b57355b77a2d Mon Sep 17 00:00:00 2001 From: Oliver Ruepp Date: Tue, 8 Mar 2011 16:37:59 +0100 Subject: [PATCH] bug #37: fix resizing when the destination sparse matrix is row major --- Eigen/src/Sparse/SparseSparseProduct.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Eigen/src/Sparse/SparseSparseProduct.h b/Eigen/src/Sparse/SparseSparseProduct.h index b7ed151b4..cade6fd54 100644 --- a/Eigen/src/Sparse/SparseSparseProduct.h +++ b/Eigen/src/Sparse/SparseSparseProduct.h @@ -133,7 +133,12 @@ static void sparse_product_impl(const Lhs& lhs, const Rhs& rhs, ResultType& res) float avgNnzPerRhsColumn = float(rhs.nonZeros())/float(cols); float ratioRes = std::min(ratioLhs * avgNnzPerRhsColumn, 1.f); - res.resize(rows, cols); + // mimics a resizeByInnerOuter: + if(ResultType::IsRowMajor) + res.resize(cols, rows); + else + res.resize(rows, cols); + res.reserve(Index(ratioRes*rows*cols)); for (Index j=0; j