MCPcopy Create free account
hub / github.com/Derious/cuMPC / eigensolver

Function eigensolver

dependence/eigen-3.4.0/test/eigensolver_complex.cpp:72–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70
71
72template<typename MatrixType> void eigensolver(const MatrixType& m)
73{
74 /* this test covers the following files:
75 ComplexEigenSolver.h, and indirectly ComplexSchur.h
76 */
77 Index rows = m.rows();
78 Index cols = m.cols();
79
80 typedef typename MatrixType::Scalar Scalar;
81 typedef typename NumTraits<Scalar>::Real RealScalar;
82
83 MatrixType a = MatrixType::Random(rows,cols);
84 MatrixType symmA = a.adjoint() * a;
85
86 ComplexEigenSolver<MatrixType> ei0(symmA);
87 VERIFY_IS_EQUAL(ei0.info(), Success);
88 VERIFY_IS_APPROX(symmA * ei0.eigenvectors(), ei0.eigenvectors() * ei0.eigenvalues().asDiagonal());
89
90 ComplexEigenSolver<MatrixType> ei1(a);
91 VERIFY_IS_EQUAL(ei1.info(), Success);
92 VERIFY_IS_APPROX(a * ei1.eigenvectors(), ei1.eigenvectors() * ei1.eigenvalues().asDiagonal());
93 // Note: If MatrixType is real then a.eigenvalues() uses EigenSolver and thus
94 // another algorithm so results may differ slightly
95 verify_is_approx_upto_permutation(a.eigenvalues(), ei1.eigenvalues());
96
97 ComplexEigenSolver<MatrixType> ei2;
98 ei2.setMaxIterations(ComplexSchur<MatrixType>::m_maxIterationsPerRow * rows).compute(a);
99 VERIFY_IS_EQUAL(ei2.info(), Success);
100 VERIFY_IS_EQUAL(ei2.eigenvectors(), ei1.eigenvectors());
101 VERIFY_IS_EQUAL(ei2.eigenvalues(), ei1.eigenvalues());
102 if (rows > 2) {
103 ei2.setMaxIterations(1).compute(a);
104 VERIFY_IS_EQUAL(ei2.info(), NoConvergence);
105 VERIFY_IS_EQUAL(ei2.getMaxIterations(), 1);
106 }
107
108 ComplexEigenSolver<MatrixType> eiNoEivecs(a, false);
109 VERIFY_IS_EQUAL(eiNoEivecs.info(), Success);
110 VERIFY_IS_APPROX(ei1.eigenvalues(), eiNoEivecs.eigenvalues());
111
112 // Regression test for issue #66
113 MatrixType z = MatrixType::Zero(rows,cols);
114 ComplexEigenSolver<MatrixType> eiz(z);
115 VERIFY((eiz.eigenvalues().cwiseEqual(0)).all());
116
117 MatrixType id = MatrixType::Identity(rows, cols);
118 VERIFY_IS_APPROX(id.operatorNorm(), RealScalar(1));
119
120 if (rows > 1 && rows < 20)
121 {
122 // Test matrix with NaN
123 a(0,0) = std::numeric_limits<typename MatrixType::RealScalar>::quiet_NaN();
124 ComplexEigenSolver<MatrixType> eiNaN(a);
125 VERIFY_IS_EQUAL(eiNaN.info(), NoConvergence);
126 }
127
128 // regression test for bug 1098
129 {

Callers 2

EIGEN_DECLARE_TESTFunction · 0.70
EIGEN_DECLARE_TESTFunction · 0.70

Calls 15

asDiagonalMethod · 0.80
setMaxIterationsMethod · 0.80
operatorNormMethod · 0.80
isIdentityMethod · 0.80
aFunction · 0.50
rowsMethod · 0.45
colsMethod · 0.45
adjointMethod · 0.45
infoMethod · 0.45
eigenvectorsMethod · 0.45
eigenvaluesMethod · 0.45

Tested by

no test coverage detected