mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Document Tridiagonalization class, remove unused types.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
MatrixXd X = MatrixXd::Random(5,5);
|
||||
MatrixXd A = X + X.transpose();
|
||||
cout << "Here is a random symmetric 5x5 matrix:" << endl << A << endl << endl;
|
||||
|
||||
Tridiagonalization<MatrixXd> triOfA(A);
|
||||
cout << "The orthogonal matrix Q is:" << endl << triOfA.matrixQ() << endl;
|
||||
cout << "The tridiagonal matrix T is:" << endl << triOfA.matrixT() << endl << endl;
|
||||
|
||||
MatrixXd Q = triOfA.matrixQ();
|
||||
MatrixXd T = triOfA.matrixT();
|
||||
cout << "Q * T * Q^T = " << endl << Q * T * Q.transpose() << endl;
|
||||
9
doc/snippets/Tridiagonalization_compute.cpp
Normal file
9
doc/snippets/Tridiagonalization_compute.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
Tridiagonalization<MatrixXf> tri;
|
||||
MatrixXf X = MatrixXf::Random(4,4);
|
||||
MatrixXf A = X + X.transpose();
|
||||
tri.compute(A);
|
||||
cout << "The matrix T in the tridiagonal decomposition of A is: " << endl;
|
||||
cout << tri.matrixT() << endl;
|
||||
tri.compute(2*A); // re-use tri to compute eigenvalues of 2A
|
||||
cout << "The matrix T in the tridiagonal decomposition of 2A is: " << endl;
|
||||
cout << tri.matrixT() << endl;
|
||||
10
doc/snippets/Tridiagonalization_decomposeInPlace.cpp
Normal file
10
doc/snippets/Tridiagonalization_decomposeInPlace.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
MatrixXd X = MatrixXd::Random(5,5);
|
||||
MatrixXd A = X + X.transpose();
|
||||
cout << "Here is a random symmetric 5x5 matrix:" << endl << A << endl << endl;
|
||||
|
||||
VectorXd diag(5);
|
||||
VectorXd subdiag(4);
|
||||
Tridiagonalization<MatrixXd>::decomposeInPlace(A, diag, subdiag);
|
||||
cout << "The orthogonal matrix Q is:" << endl << A << endl;
|
||||
cout << "The diagonal of the tridiagonal matrix T is:" << endl << diag << endl;
|
||||
cout << "The subdiagonal of the tridiagonal matrix T is:" << endl << subdiag << endl;
|
||||
13
doc/snippets/Tridiagonalization_diagonal.cpp
Normal file
13
doc/snippets/Tridiagonalization_diagonal.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
MatrixXcd X = MatrixXcd::Random(4,4);
|
||||
MatrixXcd A = X + X.adjoint();
|
||||
cout << "Here is a random self-adjoint 4x4 matrix:" << endl << A << endl << endl;
|
||||
|
||||
Tridiagonalization<MatrixXcd> triOfA(A);
|
||||
MatrixXcd T = triOfA.matrixT();
|
||||
cout << "The tridiagonal matrix T is:" << endl << triOfA.matrixT() << endl << endl;
|
||||
|
||||
cout << "We can also extract the diagonals of T directly ..." << endl;
|
||||
VectorXd diag = triOfA.diagonal();
|
||||
cout << "The diagonal is:" << endl << diag << endl;
|
||||
VectorXd subdiag = triOfA.subDiagonal();
|
||||
cout << "The subdiagonal is:" << endl << subdiag << endl;
|
||||
@@ -0,0 +1,6 @@
|
||||
Matrix4d X = Matrix4d::Random(4,4);
|
||||
Matrix4d A = X + X.transpose();
|
||||
cout << "Here is a random symmetric 4x4 matrix:" << endl << A << endl;
|
||||
Tridiagonalization<Matrix4d> triOfA(A);
|
||||
Vector3d hc = triOfA.householderCoefficients();
|
||||
cout << "The vector of Householder coefficients is:" << endl << hc << endl;
|
||||
8
doc/snippets/Tridiagonalization_packedMatrix.cpp
Normal file
8
doc/snippets/Tridiagonalization_packedMatrix.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
Matrix4d X = Matrix4d::Random(4,4);
|
||||
Matrix4d A = X + X.transpose();
|
||||
cout << "Here is a random symmetric 4x4 matrix:" << endl << A << endl;
|
||||
Tridiagonalization<Matrix4d> triOfA(A);
|
||||
Matrix4d pm = triOfA.packedMatrix();
|
||||
cout << "The packed matrix M is:" << endl << pm << endl;
|
||||
cout << "The diagonal and subdiagonal corresponds to the matrix T, which is:"
|
||||
<< endl << triOfA.matrixT() << endl;
|
||||
Reference in New Issue
Block a user