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 void solveInPlace(MatrixBase &X) const { - Index nrhs = X.cols(); - Index n = X.rows(); + /* Explicit type conversion as the Index type of MatrixBase may be wider than Index */ + eigen_assert(X.rows() <= NumTraits::highest()); + eigen_assert(X.cols() <= NumTraits::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 template void MappedSuperNodalMatrix::solveInPlace( MatrixBase&X) const { - Index n = X.rows(); - Index nrhs = X.cols(); + /* Explicit type conversion as the Index type of MatrixBase may be wider than Index */ + eigen_assert(X.rows() <= NumTraits::highest()); + eigen_assert(X.cols() <= NumTraits::highest()); + Index n = Index(X.rows()); + Index nrhs = Index(X.cols()); const Scalar * Lval = valuePtr(); // Nonzero values Matrix work(n, nrhs); // working vector work.setZero();