diff options
author | 2009-01-28 18:21:38 +0000 | |
---|---|---|
committer | 2009-01-28 18:21:38 +0000 | |
commit | 9b594ab0fbee07ecdd101be2c444be43617a6980 (patch) | |
tree | fa4717001a318720ee12e350ea1edb88117b9e13 /Eigen/src | |
parent | 9bc44094c5aaac5dc4bd494a19eafe7b32645f1a (diff) |
fix overflow in sparse product
Diffstat (limited to 'Eigen/src')
-rw-r--r-- | Eigen/src/Sparse/SparseProduct.h | 6 |
1 files 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<SparseProduct<LhsNested, RhsNested, ProductMode> > CoeffReadCost = Dynamic }; - + typedef typename ei_meta_if<ResultIsSparse, SparseMatrixBase<SparseProduct<LhsNested, RhsNested, ProductMode> >, MatrixBase<SparseProduct<LhsNested, RhsNested, ProductMode> > >::ret Base; @@ -130,7 +130,7 @@ class SparseProduct : ei_no_assignment_operator, public ei_traits<SparseProduct< : m_lhs(lhs), m_rhs(rhs) { ei_assert(lhs.cols() == rhs.rows()); - + enum { ProductIsValid = _LhsNested::ColsAtCompileTime==Dynamic || _RhsNested::RowsAtCompileTime==Dynamic @@ -182,7 +182,7 @@ struct ei_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,ColMajor,ColMajor> AmbiVector<Scalar> 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); |