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

Assertion failures with QR factorization

Tags: None
(comma "," separated)
jaafar
Registered Member
Posts
2
Karma
0
OS
Hi all,

The released version of 3.2 (as supplied via the download link on the Eigen home page) works fine for dense QR factorization, but has an assertion failure for certain inputs in the sparse case (see https://forum.kde.org/viewtopic.php?f=74&t=117474 for a similar issue). The fixed versions in the "default" and "3.2" branches on Bitbucket work for the sparse case but then fail on dense matrices. I assume the fix for one has broken the other, but am not sure. Can someone have a look?

Code: Select all
#include <iostream>
using namespace std;
#include <Eigen/Dense>
#include <Eigen/SparseQR>
using namespace Eigen;
 
int main() {
   // do a QR solve two ways (dense, sparse)
   Matrix<double, 15, 15> G;
   G << 0.01, -0.01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
    , -0.01, 0.012, -0.002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, -0.002, 0.004, -0.002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, -0.002, 0.004, -0.002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, -0.002, 0.004, -0.002, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, -0.002, 0.002, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0.01, -0.01, 0, 0, 0, 0, 0, 1, 0
    , 0, 0, 0, 0, 0, 0, -0.01, 0.012, -0.002, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, -0.002, 0.004, -0.002, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, -0.002, 0.004, -0.002, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.002, 0.004, -0.002, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.002, 0.002, 0, 0, 1
    , -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0
    , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0 ;

   Matrix<double, 15, 3> B;
   B << 0, 0, 0
      , 0, 0, 0
      , 0, 0, 0
      , 0, 0, 0
      , 0, 0, 0
      , 0, 0, 0
      , 0, 0, 0
      , 0, 0, 0
      , 0, 0, 0
      , 0, 0, 0
      , 0, 0, 0
      , 0, 0, 0
      , -1, 0, 0
      , 0, -1, 0
      , 0, 0, -1 ;

   // solve G*R = B
   // Dense solution
   Matrix<double, 15, 3> Rdense = G.fullPivHouseholderQr().solve(B);
   std::cout << "R, dense calculation:\n" << Rdense << std::endl;
   // factor the result
   auto rQRdense = Rdense.fullPivHouseholderQr();  // 3.2 and default branches assert here

   // Sparse solution
   SparseMatrix<double> Gsparse = G.sparseView();
   SparseQR<SparseMatrix<double>, COLAMDOrdering<int> > G_QR(Gsparse);
   assert(G_QR.info() == Success);
   SparseMatrix<double> Bsparse = B.sparseView();
   SparseMatrix<double> Rsparse = G_QR.solve(Bsparse);   // 3.2 download from home page asserts here
   std::cout << "R, sparse calculation:\n" << Rsparse << std::endl;
   // factor result
   SparseQR<SparseMatrix<double>, COLAMDOrdering<int> > R_QR(Rsparse);

}
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
The dense and sparse QR classes are not related at all. The problem with dense full piv QR is fixed though:

https://bitbucket.org/eigen/eigen/commits/5d557a6213f4/
Changeset: 5d557a6213f4
User: ggael
Date: 2013-11-19 12:53:46
Summary: Fix FullPivHouseholderQR ctors for non squared fixed size matrix types

https://bitbucket.org/eigen/eigen/commits/6518cd75818e/
Changeset: 6518cd75818e
Branch: 3.2
User: ggael
Date: 2013-11-19 12:53:46
Summary: Fix FullPivHouseholderQR ctors for non squared fixed size matrix types
(grafted from 5d557a6213f4a05e9bd06904edb5fa5fab519b80)


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]