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 Eigen {
00030
00031 namespace internal {
00032
00033 template<typename Derived, bool IsComplex>
00034 struct eigenvalues_selector
00035 {
00036
00037 static inline typename MatrixBase<Derived>::EigenvaluesReturnType const
00038 run(const MatrixBase<Derived>& m)
00039 {
00040 typedef typename Derived::PlainObject PlainObject;
00041 PlainObject m_eval(m);
00042 return ComplexEigenSolver<PlainObject>(m_eval, false).eigenvalues();
00043 }
00044 };
00045
00046 template<typename Derived>
00047 struct eigenvalues_selector<Derived, false>
00048 {
00049 static inline typename MatrixBase<Derived>::EigenvaluesReturnType const
00050 run(const MatrixBase<Derived>& m)
00051 {
00052 typedef typename Derived::PlainObject PlainObject;
00053 PlainObject m_eval(m);
00054 return EigenSolver<PlainObject>(m_eval, false).eigenvalues();
00055 }
00056 };
00057
00058 }
00059
00080 template<typename Derived>
00081 inline typename MatrixBase<Derived>::EigenvaluesReturnType
00082 MatrixBase<Derived>::eigenvalues() const
00083 {
00084 typedef typename internal::traits<Derived>::Scalar Scalar;
00085 return internal::eigenvalues_selector<Derived, NumTraits<Scalar>::IsComplex>::run(derived());
00086 }
00087
00102 template<typename MatrixType, unsigned int UpLo>
00103 inline typename SelfAdjointView<MatrixType, UpLo>::EigenvaluesReturnType
00104 SelfAdjointView<MatrixType, UpLo>::eigenvalues() const
00105 {
00106 typedef typename SelfAdjointView<MatrixType, UpLo>::PlainObject PlainObject;
00107 PlainObject thisAsMatrix(*this);
00108 return SelfAdjointEigenSolver<PlainObject>(thisAsMatrix, false).eigenvalues();
00109 }
00110
00111
00112
00135 template<typename Derived>
00136 inline typename MatrixBase<Derived>::RealScalar
00137 MatrixBase<Derived>::operatorNorm() const
00138 {
00139 typename Derived::PlainObject m_eval(derived());
00140
00141
00142 return internal::sqrt((m_eval*m_eval.adjoint())
00143 .eval()
00144 .template selfadjointView<Lower>()
00145 .eigenvalues()
00146 .maxCoeff()
00147 );
00148 }
00149
00165 template<typename MatrixType, unsigned int UpLo>
00166 inline typename SelfAdjointView<MatrixType, UpLo>::RealScalar
00167 SelfAdjointView<MatrixType, UpLo>::operatorNorm() const
00168 {
00169 return eigenvalues().cwiseAbs().maxCoeff();
00170 }
00171
00172 }
00173
00174 #endif