12#ifndef EIGEN_GENERALIZEDSELFADJOINTEIGENSOLVER_H
13#define EIGEN_GENERALIZEDSELFADJOINTEIGENSOLVER_H
15#include "./Tridiagonalization.h"
18#include "./InternalHeaderCheck.h"
51template <
typename MatrixType_>
56 using MatrixType = MatrixType_;
108 template <
typename InputTypeA,
typename InputTypeB>
111 : Base(matA.cols()) {
129 template <typename InputTypeA, typename InputTypeB, bool IsRef = internal::is_ref<MatrixType>::value,
130 std::enable_if_t<IsRef, int> = 0>
133 : Base(matA, typename Base::BindStorageTag()), m_cholB(matB.derived()), m_matC(matA.derived()) {
135 m_matC = m_matC.template selfadjointView<Lower>();
136 computeInPlace(options);
181 template <
typename InputTypeA,
typename InputTypeB>
195template <
typename MatrixType>
196template <
typename InputTypeA,
typename InputTypeB>
202 m_cholB.compute(matB.
derived());
203 m_matC = matA.
derived().template selfadjointView<Lower>();
204 return computeInPlace(options);
209template <
typename MatrixType>
210GeneralizedSelfAdjointEigenSolver<MatrixType>& GeneralizedSelfAdjointEigenSolver<MatrixType>::computeInPlace(
212 eigen_assert(m_matC.cols() == m_matC.rows() && m_cholB.rows() == m_matC.rows());
213 eigen_assert((options & ~(EigVecMask | GenEigMask)) == 0 && (options & EigVecMask) != EigVecMask &&
214 ((options & GenEigMask) == 0 || (options & GenEigMask) ==
Ax_lBx || (options & GenEigMask) ==
ABx_lx ||
215 (options & GenEigMask) ==
BAx_lx) &&
216 "invalid option parameter");
218 bool computeEigVecs = ((options & EigVecMask) == 0) || ((options & EigVecMask) ==
ComputeEigenvectors);
220 int type = (options & GenEigMask);
221 if (type == 0) type =
Ax_lBx;
225 const bool eivecIsMatC = internal::is_same_dense(Base::m_eivec, m_matC);
229 m_cholB.matrixL().template solveInPlace<OnTheLeft>(m_matC);
230 m_cholB.matrixU().template solveInPlace<OnTheRight>(m_matC);
235 if (computeEigVecs) m_cholB.matrixU().solveInPlace(Base::m_eivec);
236 }
else if (type ==
ABx_lx) {
240 typename Base::PlainMatrixType tmp = m_matC * m_cholB.matrixL();
241 m_matC.noalias() = m_cholB.matrixU() * tmp;
243 Base::m_eivec.noalias() = m_matC * m_cholB.matrixL();
244 m_matC.noalias() = m_cholB.matrixU() * Base::m_eivec;
250 if (computeEigVecs) m_cholB.matrixU().solveInPlace(Base::m_eivec);
251 }
else if (type ==
BAx_lx) {
254 typename Base::PlainMatrixType tmp = m_matC * m_cholB.matrixL();
255 m_matC.noalias() = m_cholB.matrixU() * tmp;
257 Base::m_eivec.noalias() = m_matC * m_cholB.matrixL();
258 m_matC.noalias() = m_cholB.matrixU() * Base::m_eivec;
265 if (computeEigVecs) {
267 Base::m_eivec = m_cholB.matrixL() * Base::m_eivec;
269 m_matC.noalias() = m_cholB.matrixL() * Base::m_eivec;
270 Base::m_eivec = m_matC;
Computes eigenvalues and eigenvectors of the generalized selfadjoint eigen problem.
Definition GeneralizedSelfAdjointEigenSolver.h:52
GeneralizedSelfAdjointEigenSolver()
Default constructor for fixed-size matrices.
Definition GeneralizedSelfAdjointEigenSolver.h:65
GeneralizedSelfAdjointEigenSolver(Index size)
Constructor, pre-allocates memory for dynamic-size matrices.
Definition GeneralizedSelfAdjointEigenSolver.h:79
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:109
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:131
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:140
Eigen::Index Index
Definition SelfAdjointEigenSolver.h:95
@ 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 Index cols() const noexcept
Definition EigenBase.h:62
constexpr Derived & derived()
Definition EigenBase.h:50
constexpr Index rows() const noexcept
Definition EigenBase.h:60