11 #ifndef EIGEN_GENERALIZEDEIGENSOLVER_H 12 #define EIGEN_GENERALIZEDEIGENSOLVER_H 65 RowsAtCompileTime = MatrixType::RowsAtCompileTime,
66 ColsAtCompileTime = MatrixType::ColsAtCompileTime,
67 Options = MatrixType::Options,
68 MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
69 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
73 typedef typename MatrixType::Scalar
Scalar;
126 : m_eivec(size, size),
129 m_isInitialized(false),
130 m_eigenvectorsOk(false),
149 : m_eivec(A.rows(), A.cols()),
152 m_isInitialized(false),
153 m_eigenvectorsOk(false),
155 m_matS(A.rows(), A.cols()),
158 compute(A, B, computeEigenvectors);
200 eigen_assert(m_isInitialized &&
"GeneralizedEigenSolver is not initialized.");
211 eigen_assert(m_isInitialized &&
"GeneralizedEigenSolver is not initialized.");
222 eigen_assert(m_isInitialized &&
"GeneralizedEigenSolver is not initialized.");
253 eigen_assert(m_isInitialized &&
"EigenSolver is not initialized.");
254 return m_realQZ.
info();
267 static void check_template_parameters()
269 EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
274 ComplexVectorType m_alphas;
276 bool m_isInitialized;
277 bool m_eigenvectorsOk;
282 ColumnVectorType m_tmp;
296 template<
typename MatrixType>
300 check_template_parameters();
304 eigen_assert(A.cols() == A.rows() && B.cols() == A.rows() && B.cols() == B.rows());
308 m_realQZ.
compute(A, B, computeEigenvectors);
314 if (computeEigenvectors)
315 m_eivec = m_realQZ.
matrixZ().transpose();
318 m_alphas.
resize(A.cols());
323 if (i == A.cols() - 1 || m_matS.coeff(i+1, i) ==
Scalar(0))
325 m_alphas.
coeffRef(i) = m_matS.coeff(i, i);
326 m_betas.
coeffRef(i) = matT.coeff(i,i);
336 RealScalar a = matT.diagonal().coeff(i),
337 b = matT.diagonal().coeff(i+1);
354 m_isInitialized =
true;
355 m_eigenvectorsOk =
false;
362 #endif // EIGEN_GENERALIZEDEIGENSOLVER_H const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
ComputationInfo info() const
Reports whether previous computation was successful.
Definition: RealQZ.h:166
VectorType betas() const
Definition: GeneralizedEigenSolver.h:220
Namespace containing all symbols from the Eigen library.
Definition: Core:271
const MatrixType & matrixT() const
Returns matrix S in the QZ decomposition.
Definition: RealQZ.h:148
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:167
std::complex< RealScalar > ComplexScalar
Complex scalar type for MatrixType.
Definition: GeneralizedEigenSolver.h:83
ComplexVectorType alphas() const
Definition: GeneralizedEigenSolver.h:209
RealQZ & setMaxIterations(Index maxIters)
Definition: RealQZ.h:183
void resize(Index rows, Index cols)
Definition: PlainObjectBase.h:273
MatrixType::Scalar Scalar
Scalar type for matrices of type MatrixType.
Definition: GeneralizedEigenSolver.h:73
GeneralizedEigenSolver & compute(const MatrixType &A, const MatrixType &B, bool computeEigenvectors=true)
Computes generalized eigendecomposition of given matrix.
Definition: GeneralizedEigenSolver.h:298
GeneralizedEigenSolver & setMaxIterations(Index maxIters)
Definition: GeneralizedEigenSolver.h:259
Scalar & coeffRef(Index rowId, Index colId)
Definition: PlainObjectBase.h:177
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:77
_MatrixType MatrixType
Synonym for the template parameter _MatrixType.
Definition: GeneralizedEigenSolver.h:62
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: XprHelper.h:35
CwiseBinaryOp< internal::scalar_quotient_op< ComplexScalar, Scalar >, ComplexVectorType, VectorType > EigenvalueType
Expression type for the eigenvalues as returned by eigenvalues().
Definition: GeneralizedEigenSolver.h:101
GeneralizedEigenSolver(Index size)
Default constructor with memory preallocation.
Definition: GeneralizedEigenSolver.h:125
const MatrixType & matrixS() const
Returns matrix S in the QZ decomposition.
Definition: RealQZ.h:139
const MatrixType & matrixZ() const
Returns matrix Z in the QZ decomposition.
Definition: RealQZ.h:129
EigenvalueType eigenvalues() const
Returns an expression of the computed generalized eigenvalues.
Definition: GeneralizedEigenSolver.h:198
Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > EigenvectorsType
Type for matrix of eigenvectors as returned by eigenvectors().
Definition: GeneralizedEigenSolver.h:108
Definition: Constants.h:432
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)
Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > ComplexVectorType
Type for vector of complex scalar values eigenvalues as returned by betas().
Definition: GeneralizedEigenSolver.h:97
RealQZ & compute(const MatrixType &A, const MatrixType &B, bool computeQZ=true)
Computes QZ decomposition of given matrix.
Definition: RealQZ.h:556
GeneralizedEigenSolver(const MatrixType &A, const MatrixType &B, bool computeEigenvectors=true)
Constructor; computes the generalized eigendecomposition of given matrix pair.
Definition: GeneralizedEigenSolver.h:148
const DiagonalWrapper< const Derived > asDiagonal() const
Definition: DiagonalMatrix.h:277
Computes the generalized eigenvalues and eigenvectors of a pair of general matrices.
Definition: GeneralizedEigenSolver.h:57
const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:154
Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > VectorType
Type for vector of real scalar values eigenvalues as returned by betas().
Definition: GeneralizedEigenSolver.h:90
ComputationInfo
Definition: Constants.h:430
GeneralizedEigenSolver()
Default constructor.
Definition: GeneralizedEigenSolver.h:117
Eigen::Index Index
Definition: GeneralizedEigenSolver.h:75