aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/SparseLU
diff options
context:
space:
mode:
authorGravatar Georg Drenkhahn <Georg.Drenkhahn@gmail.com>2014-09-22 18:47:33 +0200
committerGravatar Georg Drenkhahn <Georg.Drenkhahn@gmail.com>2014-09-22 18:47:33 +0200
commit9a04cd307c1cbb271373d6c4f32b5921da6144ef (patch)
treed44af50a90ab73d072305709d32a758bd86b36cc /Eigen/src/SparseLU
parentf0a62c90bcb59bbea04cbb3cb4cc818cda9251ce (diff)
Added implicit integer conversion by using explicit integer type conversion. Adding assert to catch overflow.
Diffstat (limited to 'Eigen/src/SparseLU')
-rw-r--r--Eigen/src/SparseLU/SparseLU.h7
-rw-r--r--Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h7
2 files changed, 10 insertions, 4 deletions
diff --git a/Eigen/src/SparseLU/SparseLU.h b/Eigen/src/SparseLU/SparseLU.h
index cd4ea5b13..1789830b9 100644
--- a/Eigen/src/SparseLU/SparseLU.h
+++ b/Eigen/src/SparseLU/SparseLU.h
@@ -675,8 +675,11 @@ struct SparseLUMatrixUReturnType : internal::no_assignment_operator
template<typename Dest> void solveInPlace(MatrixBase<Dest> &X) const
{
- Index nrhs = X.cols();
- Index n = X.rows();
+ /* Explicit type conversion as the Index type of MatrixBase<Dest> may be wider than Index */
+ eigen_assert(X.rows() <= NumTraits<Index>::highest());
+ eigen_assert(X.cols() <= NumTraits<Index>::highest());
+ Index nrhs = Index(X.cols());
+ Index n = Index(X.rows());
// Backward solve with U
for (Index k = m_mapL.nsuper(); k >= 0; k--)
{
diff --git a/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h b/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h
index ad6f2183f..6b0b83e0b 100644
--- a/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h
+++ b/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h
@@ -233,8 +233,11 @@ template<typename Scalar, typename Index>
template<typename Dest>
void MappedSuperNodalMatrix<Scalar,Index>::solveInPlace( MatrixBase<Dest>&X) const
{
- Index n = X.rows();
- Index nrhs = X.cols();
+ /* Explicit type conversion as the Index type of MatrixBase<Dest> may be wider than Index */
+ eigen_assert(X.rows() <= NumTraits<Index>::highest());
+ eigen_assert(X.cols() <= NumTraits<Index>::highest());
+ Index n = Index(X.rows());
+ Index nrhs = Index(X.cols());
const Scalar * Lval = valuePtr(); // Nonzero values
Matrix<Scalar,Dynamic,Dynamic> work(n, nrhs); // working vector
work.setZero();