MatrixBaseEigenvalues.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 // Copyright (C) 2010 Jitse Niesen <jitse@maths.leeds.ac.uk>
00006 //
00007 // This Source Code Form is subject to the terms of the Mozilla
00008 // Public License v. 2.0. If a copy of the MPL was not distributed
00009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
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   // this is the implementation for the case IsComplex = true
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 } // end namespace internal
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   // FIXME if it is really guaranteed that the eigenvalues are already sorted,
00127   // then we don't need to compute a maxCoeff() here, comparing the 1st and last ones is enough.
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 } // end namespace Eigen
00159 
00160 #endif


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:38:05