New user self-registration is currently disabled. Please email eigen-core-team @ if you need an account.
Bug 1423 - LeastSquaresConjugateGradient does handle row-major sparse matrices properly
LeastSquaresConjugateGradient does handle row-major sparse matrices properly
Product: Eigen
Classification: Unclassified
Component: Sparse
3.3 (current stable)
All All
: Normal Crash
Assigned To: Nobody
Depends on:
  Show dependency treegraph
Reported: 2017-04-25 22:52 UTC by Bailin Deng
Modified: 2017-06-08 13:07 UTC (History)
2 users (show)

Codes that reproduce the error. (1.43 KB, text/x-csrc)
2017-04-25 22:52 UTC, Bailin Deng
no flags Details

Description Bailin Deng 2017-04-25 22:52:50 UTC
Created attachment 786 [details]
Codes that reproduce the error.

When using LeastSquaresConjugateGradient for row-major sparse matrices with more rows than columns, Eigen crashes at the following function in Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h:   

    LeastSquareDiagonalPreconditioner& factorize(const MatType& mat)
      // Compute the inverse squared-norm of each column of mat
      for(Index j=0; j<mat.outerSize(); ++j)
        RealScalar sum = mat.innerVector(j).squaredNorm();
          m_invdiag(j) = RealScalar(1)/sum;
          m_invdiag(j) = RealScalar(1);
      Base::m_isInitialized = true;
      return *this;

Here the dimension of m_invdiag is the number of columns, but mat.outerSize() is the number of rows, resulting in out-of-bound access of m_invdiag in the loop.
Comment 1 Gael Guennebaud 2017-06-08 13:07:22 UTC
Thank you for the report, fixed: (devel) (3.3)

Note You need to log in before you can comment on or make changes to this bug.