12 #ifndef EIGEN_GENERALIZEDEIGENSOLVER_H 13 #define EIGEN_GENERALIZEDEIGENSOLVER_H 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)
320 if (i == size - 1 || mS.coeff(i+1, i) ==
Scalar(0))
325 if (computeEigenvectors)
327 v.setConstant(
Scalar(0.0));
328 v.coeffRef(i) =
Scalar(1.0);
339 if (j > 0 && mS.coeff(j, j-1) !=
Scalar(0))
342 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) );
343 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);
344 v.template segment<2>(j-1) = lhs.partialPivLu().solve(rhs);
349 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().normalize();
367 b = mT.diagonal().coeff(i+1);
379 if (computeEigenvectors) {
384 cv.
coeffRef(i) = -(
static_cast<Scalar>(beta*mS.coeffRef(i,i+1)) - alpha*mT.coeffRef(i,i+1))
385 / (static_cast<Scalar>(beta*mS.coeffRef(i,i)) - alpha*mT.coeffRef(i,i));
390 if (j > 0 && mS.coeff(j, j-1) !=
Scalar(0))
393 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) );
395 cv.template segment<2>(j-1) = lhs.partialPivLu().solve(rhs);
398 cv.
coeffRef(j) = cv.segment(st,sz).transpose().cwiseProduct(beta*mS.block(j,st,1,sz) - alpha*mT.block(j,st,1,sz)).sum()
399 / (alpha*mT.coeffRef(j,j) -
static_cast<Scalar>(beta*mS.coeffRef(j,j)));
418 #endif // EIGEN_GENERALIZEDEIGENSOLVER_H RealQZ< MatrixType > m_realQZ
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
const MatrixType & matrixS() const
Returns matrix S in the QZ decomposition.
EigenvalueType eigenvalues() const
Returns an expression of the computed generalized eigenvalues.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
A matrix or vector expression mapping an existing array of data.
Namespace containing all symbols from the Eigen library.
NumTraits< Scalar >::Real RealScalar
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)
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)
EigenvectorsType eigenvectors() const
GeneralizedEigenSolver & setMaxIterations(Index maxIters)
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_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
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().
Array< int, Dynamic, 1 > v
GeneralizedEigenSolver(Index size)
Default constructor with memory preallocation.
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
EIGEN_DEVICE_FUNC Derived & setConstant(Index size, const Scalar &val)
ComplexVectorType m_alphas
const MatrixType & matrixZ() const
Returns matrix Z in the QZ decomposition.
ComputationInfo info() const
Reports whether previous computation was successful.
Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > EigenvectorsType
Type for matrix of eigenvectors as returned by eigenvectors().
ComputationInfo info() const
m block< 2, Dynamic >(1, 1, 2, 3).setZero()
Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > ComplexVectorType
Type for vector of complex scalar values eigenvalues as returned by alphas().
const MatrixType & matrixT() const
Returns matrix S in the QZ decomposition.
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()
Jet< T, N > sqrt(const Jet< T, N > &f)
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)
ComplexVectorType alphas() const
GeneralizedEigenSolver()
Default constructor.