You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.3 KiB

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