Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef EIGEN_MATRIXBASEEIGENVALUES_H
00012 #define EIGEN_MATRIXBASEEIGENVALUES_H
00013
00014 namespace Eigen {
00015
00016 namespace internal {
00017
00018 template<typename Derived, bool IsComplex>
00019 struct eigenvalues_selector
00020 {
00021
00022 static inline typename MatrixBase<Derived>::EigenvaluesReturnType const
00023 run(const MatrixBase<Derived>& m)
00024 {
00025 typedef typename Derived::PlainObject PlainObject;
00026 PlainObject m_eval(m);
00027 return ComplexEigenSolver<PlainObject>(m_eval, false).eigenvalues();
00028 }
00029 };
00030
00031 template<typename Derived>
00032 struct eigenvalues_selector<Derived, false>
00033 {
00034 static inline typename MatrixBase<Derived>::EigenvaluesReturnType const
00035 run(const MatrixBase<Derived>& m)
00036 {
00037 typedef typename Derived::PlainObject PlainObject;
00038 PlainObject m_eval(m);
00039 return EigenSolver<PlainObject>(m_eval, false).eigenvalues();
00040 }
00041 };
00042
00043 }
00044
00065 template<typename Derived>
00066 inline typename MatrixBase<Derived>::EigenvaluesReturnType
00067 MatrixBase<Derived>::eigenvalues() const
00068 {
00069 typedef typename internal::traits<Derived>::Scalar Scalar;
00070 return internal::eigenvalues_selector<Derived, NumTraits<Scalar>::IsComplex>::run(derived());
00071 }
00072
00087 template<typename MatrixType, unsigned int UpLo>
00088 inline typename SelfAdjointView<MatrixType, UpLo>::EigenvaluesReturnType
00089 SelfAdjointView<MatrixType, UpLo>::eigenvalues() const
00090 {
00091 typedef typename SelfAdjointView<MatrixType, UpLo>::PlainObject PlainObject;
00092 PlainObject thisAsMatrix(*this);
00093 return SelfAdjointEigenSolver<PlainObject>(thisAsMatrix, false).eigenvalues();
00094 }
00095
00096
00097
00120 template<typename Derived>
00121 inline typename MatrixBase<Derived>::RealScalar
00122 MatrixBase<Derived>::operatorNorm() const
00123 {
00124 using std::sqrt;
00125 typename Derived::PlainObject m_eval(derived());
00126
00127
00128 return sqrt((m_eval*m_eval.adjoint())
00129 .eval()
00130 .template selfadjointView<Lower>()
00131 .eigenvalues()
00132 .maxCoeff()
00133 );
00134 }
00135
00151 template<typename MatrixType, unsigned int UpLo>
00152 inline typename SelfAdjointView<MatrixType, UpLo>::RealScalar
00153 SelfAdjointView<MatrixType, UpLo>::operatorNorm() const
00154 {
00155 return eigenvalues().cwiseAbs().maxCoeff();
00156 }
00157
00158 }
00159
00160 #endif