source: pacpussensors/trunk/Vislab/lib3dv/eigen/Eigen-install/doc/snippets/compile_RealQZ_compute.cpp@ 136

Last change on this file since 136 was 136, checked in by ldecherf, 7 years ago

Doc

File size: 999 bytes
Line 
1#include <Eigen/Dense>
2#include <iostream>
3
4using namespace Eigen;
5using namespace std;
6
7int main(int, char**)
8{
9 cout.precision(3);
10 MatrixXf A = MatrixXf::Random(4,4);
11MatrixXf B = MatrixXf::Random(4,4);
12RealQZ<MatrixXf> qz(4); // preallocate space for 4x4 matrices
13qz.compute(A,B); // A = Q S Z, B = Q T Z
14
15// print original matrices and result of decomposition
16cout << "A:\n" << A << "\n" << "B:\n" << B << "\n";
17cout << "S:\n" << qz.matrixS() << "\n" << "T:\n" << qz.matrixT() << "\n";
18cout << "Q:\n" << qz.matrixQ() << "\n" << "Z:\n" << qz.matrixZ() << "\n";
19
20// verify precision
21cout << "\nErrors:"
22 << "\n|A-QSZ|: " << (A-qz.matrixQ()*qz.matrixS()*qz.matrixZ()).norm()
23 << ", |B-QTZ|: " << (B-qz.matrixQ()*qz.matrixT()*qz.matrixZ()).norm()
24 << "\n|QQ* - I|: " << (qz.matrixQ()*qz.matrixQ().adjoint() - MatrixXf::Identity(4,4)).norm()
25 << ", |ZZ* - I|: " << (qz.matrixZ()*qz.matrixZ().adjoint() - MatrixXf::Identity(4,4)).norm()
26 << "\n";
27
28 return 0;
29}
Note: See TracBrowser for help on using the repository browser.