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

how do I get non-singular matrix using C++ Eigen QR decompo

Tags: None
(comma "," separated)
yo2xia
Registered Member
Posts
1
Karma
0
Hi all. This is my first post, so feel free to ignore if it doesn't make sense.
Here is the code I run in C++ using Eigen library ColPivHouseholderQR decomposition, and I have got the rank of matrix and want to get the non-singular matrix. But I do not know which function in QR decomposition can do this.

Code: Select all
#include <Eigen/LU>
#include <Eigen/QR>
#include <Eigen/Dense> 
#include <iostream> 
using namespace std; 
using namespace Eigen;
//*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*
//*---*---*---*---*--rank and image in QR Decomposition---*---*---*---*
//*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*

main()
{
  MatrixXd X(20,4);
  MatrixXd Y(20,1);
  MatrixXd X1(20,5);
  //int n=20,p=4;
  X <<1,1,0,0
     ,1,1,0,0
     ,1,1,0,0
     ,1,1,0,0
     ,1,1,0,0
     ,1,0,2,0
     ,1,0,2,0
     ,1,0,2,0
     ,1,0,2,0
     ,1,0,2,0
     ,1,0,0,3
     ,1,0,0,3
     ,1,0,0,3
     ,1,0,0,3
     ,1,0,0,3
     ,1,0,0,3
     ,1,0,0,3
     ,1,0,0,3
     ,1,0,0,3
     ,1,0,0,3.000001;
  Y <<50,51,52,54,53,60,59,65,67,70,70,73,74,78,82,80,87,84,88,92;
  X1<<X,Y;
  ColPivHouseholderQR<MatrixXd> qrA(X1);
  qrA.setThreshold(1e-7);
  int rank = qrA.rank();
  std::cout << "rank"<< std::endl <<rank << std::endl << std::endl; 
  //std::cout << "image"<< std::endl << image << std::endl << std::endl;
  system("pause");   
}

Thanks in advance.


Bookmarks



Who is online

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