1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include <Eigen/LU>
#include <Eigen/QR>
#include <Eigen/Dense>
#include <iostream>
using namespace std;
using namespace Eigen;
//*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*
//*---*---*---*---*--rank and image in LU Decomposition---*---*---*---*
//*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*
main()
{
MatrixXd X(20,4);
MatrixXd Y(20,1);
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;
FullPivLU<MatrixXd> luA(X);
luA.setThreshold(1e-6);
int rank = luA.rank();
MatrixXd image = luA.image(X);
std::cout << "rank"<< std::endl <<rank << std::endl << std::endl;
std::cout << "image"<< std::endl << image << std::endl << std::endl;
system("pause");
}
|