Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef EIGEN_MATRIXBASEEIGENVALUES_H
00027 #define EIGEN_MATRIXBASEEIGENVALUES_H
00028
00029 namespace internal {
00030
00031 template<typename Derived, bool IsComplex>
00032 struct eigenvalues_selector
00033 {
00034
00035 static inline typename MatrixBase<Derived>::EigenvaluesReturnType const
00036 run(const MatrixBase<Derived>& m)
00037 {
00038 typedef typename Derived::PlainObject PlainObject;
00039 PlainObject m_eval(m);
00040 return ComplexEigenSolver<PlainObject>(m_eval, false).eigenvalues();
00041 }
00042 };
00043
00044 template<typename Derived>
00045 struct eigenvalues_selector<Derived, false>
00046 {
00047 static inline typename MatrixBase<Derived>::EigenvaluesReturnType const
00048 run(const MatrixBase<Derived>& m)
00049 {
00050 typedef typename Derived::PlainObject PlainObject;
00051 PlainObject m_eval(m);
00052 return EigenSolver<PlainObject>(m_eval, false).eigenvalues();
00053 }
00054 };
00055
00056 }
00057
00078 template<typename Derived>
00079 inline typename MatrixBase<Derived>::EigenvaluesReturnType
00080 MatrixBase<Derived>::eigenvalues() const
00081 {
00082 typedef typename internal::traits<Derived>::Scalar Scalar;
00083 return internal::eigenvalues_selector<Derived, NumTraits<Scalar>::IsComplex>::run(derived());
00084 }
00085
00100 template<typename MatrixType, unsigned int UpLo>
00101 inline typename SelfAdjointView<MatrixType, UpLo>::EigenvaluesReturnType
00102 SelfAdjointView<MatrixType, UpLo>::eigenvalues() const
00103 {
00104 typedef typename SelfAdjointView<MatrixType, UpLo>::PlainObject PlainObject;
00105 PlainObject thisAsMatrix(*this);
00106 return SelfAdjointEigenSolver<PlainObject>(thisAsMatrix, false).eigenvalues();
00107 }
00108
00109
00110
00133 template<typename Derived>
00134 inline typename MatrixBase<Derived>::RealScalar
00135 MatrixBase<Derived>::operatorNorm() const
00136 {
00137 typename Derived::PlainObject m_eval(derived());
00138
00139
00140 return internal::sqrt((m_eval*m_eval.adjoint())
00141 .eval()
00142 .template selfadjointView<Lower>()
00143 .eigenvalues()
00144 .maxCoeff()
00145 );
00146 }
00147
00163 template<typename MatrixType, unsigned int UpLo>
00164 inline typename SelfAdjointView<MatrixType, UpLo>::RealScalar
00165 SelfAdjointView<MatrixType, UpLo>::operatorNorm() const
00166 {
00167 return eigenvalues().cwiseAbs().maxCoeff();
00168 }
00169
00170 #endif