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.

17 lines
819 B

  1. MatrixXf A = MatrixXf::Random(4,4);
  2. MatrixXf B = MatrixXf::Random(4,4);
  3. RealQZ<MatrixXf> qz(4); // preallocate space for 4x4 matrices
  4. qz.compute(A,B); // A = Q S Z, B = Q T Z
  5. // print original matrices and result of decomposition
  6. cout << "A:\n" << A << "\n" << "B:\n" << B << "\n";
  7. cout << "S:\n" << qz.matrixS() << "\n" << "T:\n" << qz.matrixT() << "\n";
  8. cout << "Q:\n" << qz.matrixQ() << "\n" << "Z:\n" << qz.matrixZ() << "\n";
  9. // verify precision
  10. cout << "\nErrors:"
  11. << "\n|A-QSZ|: " << (A-qz.matrixQ()*qz.matrixS()*qz.matrixZ()).norm()
  12. << ", |B-QTZ|: " << (B-qz.matrixQ()*qz.matrixT()*qz.matrixZ()).norm()
  13. << "\n|QQ* - I|: " << (qz.matrixQ()*qz.matrixQ().adjoint() - MatrixXf::Identity(4,4)).norm()
  14. << ", |ZZ* - I|: " << (qz.matrixZ()*qz.matrixZ().adjoint() - MatrixXf::Identity(4,4)).norm()
  15. << "\n";