xref: /aosp_15_r20/external/eigen/doc/snippets/Tridiagonalization_decomposeInPlace.cpp (revision bf2c37156dfe67e5dfebd6d394bad8b2ab5804d4)
1*bf2c3715SXin Li MatrixXd X = MatrixXd::Random(5,5);
2*bf2c3715SXin Li MatrixXd A = X + X.transpose();
3*bf2c3715SXin Li cout << "Here is a random symmetric 5x5 matrix:" << endl << A << endl << endl;
4*bf2c3715SXin Li 
5*bf2c3715SXin Li VectorXd diag(5);
6*bf2c3715SXin Li VectorXd subdiag(4);
7*bf2c3715SXin Li VectorXd hcoeffs(4);  // Scratch space for householder reflector.
8*bf2c3715SXin Li internal::tridiagonalization_inplace(A, diag, subdiag, hcoeffs, true);
9*bf2c3715SXin Li cout << "The orthogonal matrix Q is:" << endl << A << endl;
10*bf2c3715SXin Li cout << "The diagonal of the tridiagonal matrix T is:" << endl << diag << endl;
11*bf2c3715SXin Li cout << "The subdiagonal of the tridiagonal matrix T is:" << endl << subdiag << endl;
12