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 typename Derived::PlainObject m_eval(derived());
00125
00126
00127 return internal::sqrt((m_eval*m_eval.adjoint())
00128 .eval()
00129 .template selfadjointView<Lower>()
00130 .eigenvalues()
00131 .maxCoeff()
00132 );
00133 }
00134
00150 template<typename MatrixType, unsigned int UpLo>
00151 inline typename SelfAdjointView<MatrixType, UpLo>::RealScalar
00152 SelfAdjointView<MatrixType, UpLo>::operatorNorm() const
00153 {
00154 return eigenvalues().cwiseAbs().maxCoeff();
00155 }
00156
00157 }
00158
00159 #endif