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

Assertion using QR with a simple matrix

Tags: None
(comma "," separated)
vealmo
Registered Member
Posts
2
Karma
0
OS
Hello,

I just started to use Eigen because I need a QR decomposition in my program. But Eigen seems to crash on my system with a simple test program:

Code: Select all
#include <iostream>
#include <Eigen/Core>
#include <Eigen/QR>

//import most common Eigen types
USING_PART_OF_NAMESPACE_EIGEN

int main (int argc, char* argv[]){
   int m = 3;
   int n = 4;

   MatrixXd A (m,n);
   A(0,0) = 1;
   A(0,1) = 3;
   A(0,2) = 2;
   A(0,3) = 8;
   A(1,0) = 1;
   A(1,1) = 9;
   A(1,2) = 2;
   A(1,3) = 7;
   A(2,0) = 2;
   A(2,1) = 1;
   A(2,2) = 7;
   A(2,3) = 6;

   std::cout << "A = \n" << A << "\n";
   Eigen::QR<MatrixXd> f (A);

}


When I run this, I get the following error:
Code: Select all
/usr/local/include/eigen/Eigen/src/Core/MapBase.h:166: Eigen::MapBase<Derived>::MapBase(const typename Eigen::ei_traits<T>::Scalar*, int, int) [with Derived = Eigen::Block<Eigen::Block<Eigen::Matrix<double, 10000, 10000, 2, 10000, 10000>, 10000, 1, 1, 32>, 10000, 1, 1, 32>]: Assertion `(data == 0) || ( rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols))' failed.


Did I do something wrong or is this a bug in the lib?

Thanks!
Zmatt
Registered Member
Posts
27
Karma
0
OS
I think A need to be a square matrix
vealmo
Registered Member
Posts
2
Karma
0
OS
Zmatt wrote:I think A need to be a square matrix


But it should be possible to do a QR decompositon for a mxn matrix, where n!=m...
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Indeed, in Eigen2.0, QR was designed for matrices where m>=n. Otherwise the matrix R is not triangular but trapezoidal, and therefore it is less useful. I would recommend you Eigen3-beta1 which already allows you to perform this QR decomposition and support trapezoidal matrices. If you really need Eigen2.0, this is just a matter one line change. Finally, are you sure want the QR dec of a matrix with m<n and not its RQ dec ? (which is essentially the QR dec of the transpose of the matrix).


Bookmarks



Who is online

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