Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
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 <[email protected]>
5// Copyright (C) 2010 Jitse Niesen <[email protected]>
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// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
19namespace internal {
20
21template <typename Derived, bool IsComplex>
22struct eigenvalues_selector {
23 // this is the implementation for the case IsComplex = true
24 static inline typename MatrixBase<Derived>::EigenvaluesReturnType const run(const MatrixBase<Derived>& m) {
25 typedef typename Derived::PlainObject PlainObject;
26 PlainObject m_eval(m);
27 return ComplexEigenSolver<PlainObject>(m_eval, false).eigenvalues();
28 }
29};
30
31template <typename Derived>
32struct eigenvalues_selector<Derived, false> {
33 static inline typename MatrixBase<Derived>::EigenvaluesReturnType const run(const MatrixBase<Derived>& m) {
34 typedef typename Derived::PlainObject PlainObject;
35 PlainObject m_eval(m);
36 return EigenSolver<PlainObject>(m_eval, false).eigenvalues();
37 }
38};
39
40} // end namespace internal
41
62template <typename Derived>
64 return internal::eigenvalues_selector<Derived, NumTraits<Scalar>::IsComplex>::run(derived());
65}
66
81template <typename MatrixType, unsigned int UpLo>
84 PlainObject thisAsMatrix(*this);
85 return SelfAdjointEigenSolver<PlainObject>(thisAsMatrix, false).eigenvalues();
86}
87
110template <typename Derived>
111inline typename MatrixBase<Derived>::RealScalar MatrixBase<Derived>::operatorNorm() const {
112 using std::sqrt;
113 typename Derived::PlainObject m_eval(derived());
114 // FIXME if it is really guaranteed that the eigenvalues are already sorted,
115 // then we don't need to compute a maxCoeff() here, comparing the 1st and last ones is enough.
116 return sqrt((m_eval * m_eval.adjoint()).eval().template selfadjointView<Lower>().eigenvalues().maxCoeff());
117}
118
134template <typename MatrixType, unsigned int UpLo>
135EIGEN_DEVICE_FUNC inline typename SelfAdjointView<MatrixType, UpLo>::RealScalar
137 return eigenvalues().cwiseAbs().maxCoeff();
138}
139
140} // end namespace Eigen
141
142#endif
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:52
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:186
Computes eigenvalues and eigenvectors of selfadjoint matrices.
Definition SelfAdjointEigenSolver.h:82
const RealVectorType & eigenvalues() const
Returns the eigenvalues of given matrix.
Definition SelfAdjointEigenSolver.h:300
Expression of a selfadjoint matrix from a triangular part of a dense matrix.
Definition SelfAdjointView.h:51
NumTraits< Scalar >::Real RealScalar
Definition SelfAdjointView.h:228
Namespace containing all symbols from the Eigen library.
Definition Core:137