Search code examples
eigenleast-squares

Eigen library - least squares


I want to use a least squares problem with the use of Eigen library. My options are 2,

  • sysAAA.jacobiSvd( Eigen::ComputeThinU | Eigen::ComputeThinV ).solve( sysBBB )
  • sysAAA.colPivHouseholderQr().solve( sysBBB );

I was using the first in the beginning, but it proved to be very slow (1)(2).

So I went to the second solution (other methods aren't appropriate for my case, because they require special matrices (2) )

Does colPivHouseholderQr().solve give a least squares solution?

My impression is that it doesn't (3), but I want to be sure before looking for a "workaround".

  1. http://forum.kde.org/viewtopic.php?f=74&t=102088
  2. http://eigen.tuxfamily.org/dox/TopicLinearAlgebraDecompositions.html
  3. http://eigen.tuxfamily.org/dox/TutorialLinearAlgebra.html#TutorialLinAlgLeastsquares

Solution

  • Yes, ColPivHouseholderQr::solve() computes a least-square solution.