Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 1 | Matrix3d v = Matrix3d::Random(); |
| 2 | cout << "The matrix v is:" << endl; |
| 3 | cout << v << endl; |
| 4 | |
| 5 | Vector3d v0(1, v(1,0), v(2,0)); |
| 6 | cout << "The first Householder vector is: v_0 = " << v0.transpose() << endl; |
| 7 | Vector3d v1(0, 1, v(2,1)); |
| 8 | cout << "The second Householder vector is: v_1 = " << v1.transpose() << endl; |
| 9 | Vector3d v2(0, 0, 1); |
| 10 | cout << "The third Householder vector is: v_2 = " << v2.transpose() << endl; |
| 11 | |
| 12 | Vector3d h = Vector3d::Random(); |
| 13 | cout << "The Householder coefficients are: h = " << h.transpose() << endl; |
| 14 | |
| 15 | Matrix3d H0 = Matrix3d::Identity() - h(0) * v0 * v0.adjoint(); |
| 16 | cout << "The first Householder reflection is represented by H_0 = " << endl; |
| 17 | cout << H0 << endl; |
| 18 | Matrix3d H1 = Matrix3d::Identity() - h(1) * v1 * v1.adjoint(); |
| 19 | cout << "The second Householder reflection is represented by H_1 = " << endl; |
| 20 | cout << H1 << endl; |
| 21 | Matrix3d H2 = Matrix3d::Identity() - h(2) * v2 * v2.adjoint(); |
| 22 | cout << "The third Householder reflection is represented by H_2 = " << endl; |
| 23 | cout << H2 << endl; |
| 24 | cout << "Their product is H_0 H_1 H_2 = " << endl; |
| 25 | cout << H0 * H1 * H2 << endl; |
| 26 | |
| 27 | HouseholderSequence<Matrix3d, Vector3d> hhSeq(v, h); |
| 28 | Matrix3d hhSeqAsMatrix(hhSeq); |
| 29 | cout << "If we construct a HouseholderSequence from v and h" << endl; |
| 30 | cout << "and convert it to a matrix, we get:" << endl; |
| 31 | cout << hhSeqAsMatrix << endl; |