Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
 Eigen  3.3.9
MatrixBaseEigenvalues.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2010 Jitse Niesen <jitse@maths.leeds.ac.uk>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
11 #ifndef EIGEN_MATRIXBASEEIGENVALUES_H
12 #define EIGEN_MATRIXBASEEIGENVALUES_H
13
14 namespace Eigen {
15
16 namespace internal {
17
18 template<typename Derived, bool IsComplex>
19 struct eigenvalues_selector
20 {
21  // this is the implementation for the case IsComplex = true
22  static inline typename MatrixBase<Derived>::EigenvaluesReturnType const
23  run(const MatrixBase<Derived>& m)
24  {
25  typedef typename Derived::PlainObject PlainObject;
26  PlainObject m_eval(m);
27  return ComplexEigenSolver<PlainObject>(m_eval, false).eigenvalues();
28  }
29 };
30
31 template<typename Derived>
32 struct eigenvalues_selector<Derived, false>
33 {
34  static inline typename MatrixBase<Derived>::EigenvaluesReturnType const
35  run(const MatrixBase<Derived>& m)
36  {
37  typedef typename Derived::PlainObject PlainObject;
38  PlainObject m_eval(m);
39  return EigenSolver<PlainObject>(m_eval, false).eigenvalues();
40  }
41 };
42
43 } // end namespace internal
44
65 template<typename Derived>
66 inline typename MatrixBase<Derived>::EigenvaluesReturnType
68 {
69  return internal::eigenvalues_selector<Derived, NumTraits<Scalar>::IsComplex>::run(derived());
70 }
71
86 template<typename MatrixType, unsigned int UpLo>
89 {
90  PlainObject thisAsMatrix(*this);
92 }
93
94
95
118 template<typename Derived>
119 inline typename MatrixBase<Derived>::RealScalar
121 {
122  using std::sqrt;
123  typename Derived::PlainObject m_eval(derived());
124  // FIXME if it is really guaranteed that the eigenvalues are already sorted,
125  // then we don't need to compute a maxCoeff() here, comparing the 1st and last ones is enough.
127  .eval()
129  .eigenvalues()
130  .maxCoeff()
131  );
132 }
133
149 template<typename MatrixType, unsigned int UpLo>
152 {
153  return eigenvalues().cwiseAbs().maxCoeff();
154 }
155
156 } // end namespace Eigen
157
158 #endif
Eigen
Namespace containing all symbols from the Eigen library.
Definition: Core:309
NumTraits< Scalar >::Real RealScalar
Eigen::sqrt
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
RealScalar operatorNorm() const
Computes the L2 operator norm.
Definition: MatrixBaseEigenvalues.h:151
const RealVectorType & eigenvalues() const
Returns the eigenvalues of given matrix.
Eigen::MatrixBase::eigenvalues
EigenvaluesReturnType eigenvalues() const
Computes the eigenvalues of a matrix.
Definition: MatrixBaseEigenvalues.h:67
Eigen::MatrixBase::operatorNorm
RealScalar operatorNorm() const
Computes the L2 operator norm.
Definition: MatrixBaseEigenvalues.h:120