From 9b594ab0fbee07ecdd101be2c444be43617a6980 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 28 Jan 2009 18:21:38 +0000 Subject: [PATCH] fix overflow in sparse product --- Eigen/src/Sparse/SparseProduct.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Eigen/src/Sparse/SparseProduct.h b/Eigen/src/Sparse/SparseProduct.h index ec4961d9b..f3cf465f1 100644 --- a/Eigen/src/Sparse/SparseProduct.h +++ b/Eigen/src/Sparse/SparseProduct.h @@ -105,7 +105,7 @@ struct ei_traits > CoeffReadCost = Dynamic }; - + typedef typename ei_meta_if >, MatrixBase > >::ret Base; @@ -130,7 +130,7 @@ class SparseProduct : ei_no_assignment_operator, public ei_traits AmbiVector tempVector(rows); // estimate the number of non zero entries - float ratioLhs = float(lhs.nonZeros())/float(lhs.rows()*lhs.cols()); + float ratioLhs = float(lhs.nonZeros())/(float(lhs.rows())*float(lhs.cols())); float avgNnzPerRhsColumn = float(rhs.nonZeros())/float(cols); float ratioRes = std::min(ratioLhs * avgNnzPerRhsColumn, 1.f);