12 #ifndef EIGEN_GENERALIZEDEIGENSOLVER_H 13 #define EIGEN_GENERALIZEDEIGENSOLVER_H 74 typedef typename MatrixType::Scalar
Scalar;
164 compute(A, B, computeEigenvectors);
285 template<
typename MatrixType>
293 eigen_assert(A.cols() == A.rows() && B.cols() == A.rows() && B.cols() == B.rows());
305 if (computeEigenvectors)
321 if (i == size - 1 || mS.coeff(i+1, i) ==
Scalar(0))
326 if (computeEigenvectors)
328 v.setConstant(
Scalar(0.0));
329 v.coeffRef(i) =
Scalar(1.0);
336 for (
Index j = i-1; j >= 0; j--)
338 const Index st = j+1;
339 const Index sz = i-j;
340 if (j > 0 && mS.coeff(j, j-1) !=
Scalar(0))
343 Matrix<Scalar, 2, 1> rhs = (alpha*mT.template block<2,Dynamic>(j-1,st,2,sz) - beta*mS.template block<2,Dynamic>(j-1,st,2,sz)) .lazyProduct( v.segment(st,sz) );
344 Matrix<Scalar, 2, 2> lhs = beta * mS.template block<2,2>(j-1,j-1) - alpha * mT.template block<2,2>(j-1,j-1);
345 v.template segment<2>(j-1) = lhs.partialPivLu().solve(rhs);
350 v.coeffRef(j) = -v.segment(st,sz).transpose().cwiseProduct(beta*mS.block(j,st,1,sz) - alpha*mT.block(j,st,1,sz)).
sum() / (beta*mS.coeffRef(j,j) - alpha*mT.coeffRef(j,j));
354 m_eivec.col(i).real().noalias() = mZ.transpose() * v;
355 m_eivec.col(i).real().normalize();
368 b = mT.diagonal().coeff(i+1);
380 if (computeEigenvectors) {
385 cv.
coeffRef(i) = -(
static_cast<Scalar>(beta*mS.coeffRef(i,i+1)) - alpha*mT.coeffRef(i,i+1))
386 / (static_cast<Scalar>(beta*mS.coeffRef(i,i)) - alpha*mT.coeffRef(i,i));
387 for (
Index j = i-1; j >= 0; j--)
389 const Index st = j+1;
390 const Index sz = i+1-j;
391 if (j > 0 && mS.coeff(j, j-1) !=
Scalar(0))
394 Matrix<ComplexScalar, 2, 1> rhs = (alpha*mT.template block<2,Dynamic>(j-1,st,2,sz) - beta*mS.template block<2,Dynamic>(j-1,st,2,sz)) .lazyProduct( cv.segment(st,sz) );
396 cv.template segment<2>(j-1) = lhs.partialPivLu().solve(rhs);
399 cv.
coeffRef(j) = cv.segment(st,sz).transpose().cwiseProduct(beta*mS.block(j,st,1,sz) - alpha*mT.block(j,st,1,sz)).
sum()
400 / (alpha*mT.coeffRef(j,j) -
static_cast<Scalar>(beta*mS.coeffRef(j,j)));
403 m_eivec.col(i+1).noalias() = (mZ.transpose() * cv);
419 #endif // EIGEN_GENERALIZEDEIGENSOLVER_H RealQZ< MatrixType > m_realQZ
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
A matrix or vector expression mapping an existing array of data.
ComputationInfo info() const
Reports whether previous computation was successful.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
NumTraits< Scalar >::Real RealScalar
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
const MatrixType & matrixT() const
Returns matrix S in the QZ decomposition.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
std::complex< RealScalar > ComplexScalar
Complex scalar type for MatrixType.
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
ComplexVectorType alphas() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
RealQZ & setMaxIterations(Index maxIters)
MatrixType::Scalar Scalar
Scalar type for matrices of type MatrixType.
GeneralizedEigenSolver & compute(const MatrixType &A, const MatrixType &B, bool computeEigenvectors=true)
Computes generalized eigendecomposition of given matrix.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
GeneralizedEigenSolver & setMaxIterations(Index maxIters)
EigenvectorsType eigenvectors() const
Generic expression where a coefficient-wise binary operator is applied to two expressions.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
_MatrixType MatrixType
Synonym for the template parameter _MatrixType.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
CwiseBinaryOp< internal::scalar_quotient_op< ComplexScalar, Scalar >, ComplexVectorType, VectorType > EigenvalueType
Expression type for the eigenvalues as returned by eigenvalues().
GeneralizedEigenSolver(Index size)
Default constructor with memory preallocation.
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
const MatrixType & matrixS() const
Returns matrix S in the QZ decomposition.
const mpreal sum(const mpreal tab[], const unsigned long int n, int &status, mp_rnd_t mode=mpreal::get_default_rnd())
EIGEN_DEVICE_FUNC Derived & setConstant(Index size, const Scalar &val)
ComplexVectorType m_alphas
const MatrixType & matrixZ() const
Returns matrix Z in the QZ decomposition.
EigenvalueType eigenvalues() const
Returns an expression of the computed generalized eigenvalues.
Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > EigenvectorsType
Type for matrix of eigenvectors as returned by eigenvectors().
TFSIMD_FORCE_INLINE const tfScalar & z() const
Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > ComplexVectorType
Type for vector of complex scalar values eigenvalues as returned by alphas().
RealQZ & compute(const MatrixType &A, const MatrixType &B, bool computeQZ=true)
Computes QZ decomposition of given matrix.
GeneralizedEigenSolver(const MatrixType &A, const MatrixType &B, bool computeEigenvectors=true)
Constructor; computes the generalized eigendecomposition of given matrix pair.
static void check_template_parameters()
Computes the generalized eigenvalues and eigenvectors of a pair of general matrices.
Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > VectorType
Type for vector of real scalar values eigenvalues as returned by betas().
const AutoDiffScalar< DerType > & real(const AutoDiffScalar< DerType > &x)
EIGEN_DEVICE_FUNC const Scalar & b
ComputationInfo info() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
GeneralizedEigenSolver()
Default constructor.