48 unsigned int nbok = 0;
52 typedef Eigen2::Vector Vector2;
53 typedef Eigen2::Matrix Matrix2;
59 A.setComponent( 0, 0, 4 );
60 A.setComponent( 0, 1, 1 );
61 A.setComponent( 1, 0, 1 );
62 A.setComponent( 1, 1, 2 );
65 Eigen2::getEigenDecomposition( A, P, v );
66 trace.
info() <<
"Input matrix: " << A << std::endl;
67 trace.
info() <<
"Eigenvectors: " << P << std::endl;
68 trace.
info() <<
"Eigenvalues: " << v << std::endl;
69 Vector2 V0 = P.column( 0 );
70 Vector2 V1 = P.column( 1 );
71 Vector2 V0_exp( 0.3826834323650898, -0.9238795325112868 );
72 Vector2 V1_exp( 0.9238795325112868, 0.3826834323650898);
73 double v0_exp = 1.585786437626905;
74 double v1_exp = 4.414213562373095;
75 double error_V0 = (V0-V0_exp).norm();
76 double error_V1 = (V1-V1_exp).norm();
77 double error_v0 = fabs( v[0] - v0_exp );
78 double error_v1 = fabs( v[1] - v1_exp );
79 trace.
info() <<
"error_V0 = " << error_V0 << std::endl;
80 trace.
info() <<
"error_V1 = " << error_V1 << std::endl;
81 trace.
info() <<
"error_v0 = " << error_v0 << std::endl;
82 trace.
info() <<
"error_v1 = " << error_v1 << std::endl;
83 double epsilon = 1e-10;
84 ++nb; nbok += error_V0 < epsilon ? 1 : 0;
85 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
86 <<
"error_V0 < epsilon, i.e. " << error_V0 <<
" < " << epsilon << std::endl;
87 ++nb; nbok += error_V1 < epsilon ? 1 : 0;
88 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
89 <<
"error_V1 < epsilon, i.e. " << error_V1 <<
" < " << epsilon << std::endl;
90 ++nb; nbok += error_v0 < epsilon ? 1 : 0;
91 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
92 <<
"error_v0 < epsilon, i.e. " << error_v0 <<
" < " << epsilon << std::endl;
93 ++nb; nbok += error_v1 < epsilon ? 1 : 0;
94 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
95 <<
"error_v1 < epsilon, i.e. " << error_v1 <<
" < " << epsilon << std::endl;