12#ifndef EIGEN_GENERALIZEDSELFADJOINTEIGENSOLVER_H
13#define EIGEN_GENERALIZEDSELFADJOINTEIGENSOLVER_H
15#include "./Tridiagonalization.h"
18#include "./InternalHeaderCheck.h"
52template <
typename MatrixType_>
57 using MatrixType = MatrixType_;
111 template <
typename InputTypeA,
typename InputTypeB>
114 : Base(matA.cols()) {
134 template <typename InputTypeA, typename InputTypeB, bool IsRef = internal::is_ref<MatrixType>::value,
135 std::enable_if_t<IsRef, int> = 0>
138 : Base(matA, typename Base::BindStorageTag()), m_cholB(matB.derived()), m_matC(matA.derived()) {
140 m_matC = m_matC.template selfadjointView<Lower>();
141 computeInPlace(options);
188 template <
typename InputTypeA,
typename InputTypeB>
202template <
typename MatrixType>
203template <
typename InputTypeA,
typename InputTypeB>
206 EIGEN_INTERNAL_ASSERT_SQUARE(matA);
207 EIGEN_INTERNAL_ASSERT_SAME_SHAPE(matA, matB);
210 m_cholB.compute(matB.
derived());
211 m_matC = matA.
derived().template selfadjointView<Lower>();
212 return computeInPlace(options);
217template <
typename MatrixType>
218GeneralizedSelfAdjointEigenSolver<MatrixType>& GeneralizedSelfAdjointEigenSolver<MatrixType>::computeInPlace(
220 EIGEN_INTERNAL_ASSERT_SQUARE(m_matC);
221 EIGEN_INTERNAL_ASSERT_SAME_ROWS(m_cholB, m_matC);
222 eigen_assert((options & ~(EigVecMask | GenEigMask)) == 0 && (options & EigVecMask) != EigVecMask &&
223 ((options & GenEigMask) == 0 || (options & GenEigMask) ==
Ax_lBx || (options & GenEigMask) ==
ABx_lx ||
224 (options & GenEigMask) ==
BAx_lx) &&
225 "invalid option parameter");
227 bool computeEigVecs = ((options & EigVecMask) == 0) || ((options & EigVecMask) ==
ComputeEigenvectors);
229 int type = (options & GenEigMask);
230 if (type == 0) type =
Ax_lBx;
235 EIGEN_IF_CONSTEXPR (NumTraits<typename MatrixType::Scalar>::IsComplex) {
236 m_matC.diagonal() = m_matC.diagonal().real();
241 const bool eivecIsMatC = internal::is_same_dense(Base::m_eivec, m_matC);
245 m_cholB.matrixL().template solveInPlace<OnTheLeft>(m_matC);
246 m_cholB.matrixU().template solveInPlace<OnTheRight>(m_matC);
251 if (computeEigVecs) m_cholB.matrixU().solveInPlace(Base::m_eivec);
252 }
else if (type ==
ABx_lx) {
256 typename Base::PlainMatrixType tmp = m_matC * m_cholB.matrixL();
257 m_matC.noalias() = m_cholB.matrixU() * tmp;
259 Base::m_eivec.noalias() = m_matC * m_cholB.matrixL();
260 m_matC.noalias() = m_cholB.matrixU() * Base::m_eivec;
266 if (computeEigVecs) m_cholB.matrixU().solveInPlace(Base::m_eivec);
267 }
else if (type ==
BAx_lx) {
270 typename Base::PlainMatrixType tmp = m_matC * m_cholB.matrixL();
271 m_matC.noalias() = m_cholB.matrixU() * tmp;
273 Base::m_eivec.noalias() = m_matC * m_cholB.matrixL();
274 m_matC.noalias() = m_cholB.matrixU() * Base::m_eivec;
281 if (computeEigVecs) {
283 Base::m_eivec = m_cholB.matrixL() * Base::m_eivec;
285 m_matC.noalias() = m_cholB.matrixL() * Base::m_eivec;
286 Base::m_eivec = m_matC;
Computes eigenvalues and eigenvectors of the generalized selfadjoint eigen problem.
Definition GeneralizedSelfAdjointEigenSolver.h:53
GeneralizedSelfAdjointEigenSolver()
Default constructor for fixed-size matrices.
Definition GeneralizedSelfAdjointEigenSolver.h:66
GeneralizedSelfAdjointEigenSolver(Index size)
Constructor, pre-allocates memory for dynamic-size matrices.
Definition GeneralizedSelfAdjointEigenSolver.h:80
GeneralizedSelfAdjointEigenSolver(const EigenBase< InputTypeA > &matA, const EigenBase< InputTypeB > &matB, int options=ComputeEigenvectors|Ax_lBx)
Constructor; computes generalized eigendecomposition of given matrix pencil.
Definition GeneralizedSelfAdjointEigenSolver.h:112
GeneralizedSelfAdjointEigenSolver & compute(const EigenBase< InputTypeA > &matA, const EigenBase< InputTypeB > &matB, int options=ComputeEigenvectors|Ax_lBx)
Computes generalized eigendecomposition of given matrix pencil.
GeneralizedSelfAdjointEigenSolver(EigenBase< InputTypeA > &matA, EigenBase< InputTypeB > &matB, int options=ComputeEigenvectors|Ax_lBx)
Constructor for inplace decomposition .
Definition GeneralizedSelfAdjointEigenSolver.h:136
Standard Cholesky decomposition (LL^T) of a matrix and associated features.
Definition LLT.h:85
SelfAdjointEigenSolver()
Default constructor for fixed-size matrices.
Definition SelfAdjointEigenSolver.h:141
Eigen::Index Index
Definition SelfAdjointEigenSolver.h:96
@ NumericalIssue
Definition Constants.h:459
@ Success
Definition Constants.h:457
@ Ax_lBx
Definition Constants.h:411
@ ComputeEigenvectors
Definition Constants.h:406
@ BAx_lx
Definition Constants.h:417
@ ABx_lx
Definition Constants.h:414
@ EigenvaluesOnly
Definition Constants.h:403
Definition EigenBase.h:34
constexpr Derived & derived()
Definition EigenBase.h:50