gtsam
3rdparty
Eigen
doc
snippets
SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.cpp
Go to the documentation of this file.
1
MatrixXd
X
= MatrixXd::Random(5,5);
2
MatrixXd
A
=
X
+
X
.transpose();
3
cout <<
"Here is a random symmetric 5x5 matrix, A:"
<< endl <<
A
<< endl << endl;
4
5
SelfAdjointEigenSolver<MatrixXd>
es
(
A
);
6
cout <<
"The eigenvalues of A are:"
<< endl <<
es
.eigenvalues() << endl;
7
cout <<
"The matrix of eigenvectors, V, is:"
<< endl <<
es
.eigenvectors() << endl << endl;
8
9
double
lambda
=
es
.eigenvalues()[0];
10
cout <<
"Consider the first eigenvalue, lambda = "
<<
lambda
<< endl;
11
VectorXd
v
=
es
.eigenvectors().col(0);
12
cout <<
"If v is the corresponding eigenvector, then lambda * v = "
<< endl <<
lambda
*
v
<< endl;
13
cout <<
"... and A * v = "
<< endl <<
A
*
v
<< endl << endl;
14
15
MatrixXd
D
=
es
.eigenvalues().asDiagonal();
16
MatrixXd
V
=
es
.eigenvectors();
17
cout <<
"Finally, V * D * V^(-1) = "
<< endl <<
V
*
D
*
V
.inverse() << endl;
X
MatrixXd X
Definition:
SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.cpp:1
D
MatrixXcd D
Definition:
EigenSolver_EigenSolver_MatrixType.cpp:14
A
Definition:
test_numpy_dtypes.cpp:298
lambda
static double lambda[]
Definition:
jv.c:524
v
Array< int, Dynamic, 1 > v
Definition:
Array_initializer_list_vector_cxx11.cpp:1
V
MatrixXcd V
Definition:
EigenSolver_EigenSolver_MatrixType.cpp:15
es
cout<< "Here is a random symmetric 5x5 matrix, A:"<< endl<< A<< endl<< endl;SelfAdjointEigenSolver< MatrixXd > es(A)
gtsam
Author(s):
autogenerated on Mon Jul 1 2024 03:03:08