4

I am using Eigen::SPQR module to solve a least-squares problem Ax = b, and I am getting an error complaining about rows mismatch at the solve step. In general my code consists of initializing A using triplets, b using bracket operators and then computing QR decomposition and finally solving.

Eigen::SparseMatrix<double> A;
// Fill A using triplets

Eigen::VectorXd b(A.rows()); 
// Fill b using square bracket operator b[i] = ...

Eigen::SPQR< Eigen::SparseMatrix < double > > QR(A);

Eigen::VectorXd X = QR.solve(b); // Line giving error. 

Vector b was created with size equal to A.rows() so I am sure it is correct. However, when I check the function QR.rows() it returns the value of A.cols(). Is this some kind of bug? I checked that Eigen::SparseQR solves it without errors but it is a lot slower, so I would like to use the SuiteSparse module instead. Any ideas?

jrbedard
  • 3,662
  • 5
  • 30
  • 34
marios13
  • 41
  • 3
  • This is odd, as Eigen's unit tests are running on rectangular matrices too. Make sure you are using latest releases (3.2.10 or 3.3-rc1). – ggael Oct 12 '16 at 14:06
  • Thanks for the reply. I am using Eigen 3.2.10. Maybe I should move to 3.3-rc1 ? Or it wouldn't make any difference? – marios13 Oct 12 '16 at 14:17
  • I tested 3.3-rc1. Same error. And only using the SuiteSparse Eigen::SPQR module. The Eigen::SparseQR works fine. – marios13 Oct 12 '16 at 14:56
  • You are right, this is now fixed in 3.2 and 3.3 branches. – ggael Oct 12 '16 at 20:40
  • Thank you very much. Can I download a version with this problem fixed? – marios13 Oct 13 '16 at 11:07
  • See this (link)[https://bitbucket.org/eigen/eigen/downloads?tab=branches]. – ggael Oct 14 '16 at 08:04

0 Answers0