This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1423 - LeastSquaresConjugateGradient does handle row-major sparse matrices properly
Summary: LeastSquaresConjugateGradient does handle row-major sparse matrices properly
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Crash
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-25 22:52 UTC by Bailin Deng
Modified: 2019-12-04 16:58 UTC (History)
2 users (show)



Attachments
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
      m_invdiag.resize(mat.cols());
      for(Index j=0; j<mat.outerSize(); ++j)
      {
        RealScalar sum = mat.innerVector(j).squaredNorm();
        if(sum>0)
          m_invdiag(j) = RealScalar(1)/sum;
        else
          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:

https://bitbucket.org/eigen/eigen/commits/45a5c5dde931/ (devel)
https://bitbucket.org/eigen/eigen/commits/9688211a9ef2/ (3.3)
Comment 2 Nobody 2019-12-04 16:58:23 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1423.

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