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

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

Doc

File size: 1.5 KB
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 Matrix3d v = Matrix3d::Random();
11cout << "The matrix v is:" << endl;
12cout << v << endl;
13
14Vector3d v0(1, v(1,0), v(2,0));
15cout << "The first Householder vector is: v_0 = " << v0.transpose() << endl;
16Vector3d v1(0, 1, v(2,1));
17cout << "The second Householder vector is: v_1 = " << v1.transpose() << endl;
18Vector3d v2(0, 0, 1);
19cout << "The third Householder vector is: v_2 = " << v2.transpose() << endl;
20
21Vector3d h = Vector3d::Random();
22cout << "The Householder coefficients are: h = " << h.transpose() << endl;
23
24Matrix3d H0 = Matrix3d::Identity() - h(0) * v0 * v0.adjoint();
25cout << "The first Householder reflection is represented by H_0 = " << endl;
26cout << H0 << endl;
27Matrix3d H1 = Matrix3d::Identity() - h(1) * v1 * v1.adjoint();
28cout << "The second Householder reflection is represented by H_1 = " << endl;
29cout << H1 << endl;
30Matrix3d H2 = Matrix3d::Identity() - h(2) * v2 * v2.adjoint();
31cout << "The third Householder reflection is represented by H_2 = " << endl;
32cout << H2 << endl;
33cout << "Their product is H_0 H_1 H_2 = " << endl;
34cout << H0 * H1 * H2 << endl;
35
36HouseholderSequence<Matrix3d, Vector3d> hhSeq(v, h);
37Matrix3d hhSeqAsMatrix(hhSeq);
38cout << "If we construct a HouseholderSequence from v and h" << endl;
39cout << "and convert it to a matrix, we get:" << endl;
40cout << hhSeqAsMatrix << endl;
41
42 return 0;
43}
Note: See TracBrowser for help on using the repository browser.