This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Conjugate Gradient fails assertion

Tags: None
(comma "," separated)
istrand
Registered Member
Posts
1
Karma
0

Conjugate Gradient fails assertion

Mon Mar 10, 2014 11:53 am
I have a problem which is possible to solve with Cholesky, however when I attempt to solve it with Conjugate Gradient I get a strange assertion failed message. The message is
Assertion failed: rows()==b.rows() && "IterativeSolverBase::solve(): invalid number of rows of the right hand side matrix b", file iterativelinearsolvers\iterativesolversbase.h, line 171
, I don't understand why this is the case, the number of columns in the right hand side looks to be correct. What would cause the solver to fail?

Code: Select all
        // emRec.rows == 300, emRec.cols == 200, emInPoints.rows == 200, emInPoints.cols == 3

   //Eigen::SimplicialCholesky<Eigen::SparseMatrix<float>> esmLMSSolver;
   Eigen::ConjugateGradient<Eigen::SparseMatrix<float>> esmLMSSolver;
   emSquare = emRec.transpose()*emRec;
   esmLMSSolver.compute(emSquare);

   Eigen::MatrixXf emOutPointsSolved(emInPoints.rows(),3);
   emOutPointsSolved = esmLMSSolver.solve(emInPoints);


User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
works for me:
Code: Select all
#include <Eigen/Sparse>
using namespace Eigen;
int main() {
 
  SparseMatrix<float> emRec(300,200), emSquare;
  MatrixXf emInPoints(200,3);
  emInPoints.setRandom();
  emRec = MatrixXf::Random(300,200).sparseView(0.5);
 
  ConjugateGradient<Eigen::SparseMatrix<float> > esmLMSSolver;
  emSquare = emRec.transpose()*emRec;
  esmLMSSolver.compute(emSquare);

  MatrixXf emOutPointsSolved(emInPoints.rows(),3);
  emOutPointsSolved = esmLMSSolver.solve(emInPoints);
}


Make sure that emSquare has not been deleted or changed before calling the solve function (see http://eigen.tuxfamily.org/dox/classEig ... 7586a6f6a0)


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot]