Go to the documentation of this file.
12 #ifndef EIGEN_GENERALIZEDEIGENSOLVER_H
13 #define EIGEN_GENERALIZEDEIGENSOLVER_H
285 template<
typename MatrixType>
289 check_template_parameters();
295 m_valuesOkay =
false;
296 m_vectorsOkay =
false;
299 m_realQZ.compute(
A,
B, computeEigenvectors);
300 if (m_realQZ.info() ==
Success)
303 m_alphas.resize(
size);
304 m_betas.resize(
size);
305 if (computeEigenvectors)
323 m_alphas.coeffRef(
i) = mS.diagonal().coeff(
i);
324 m_betas.coeffRef(
i) = mT.diagonal().coeff(
i);
325 if (computeEigenvectors)
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) );
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));
353 m_eivec.col(
i).real().noalias() = m_realQZ.matrixZ().transpose() *
v;
354 m_eivec.col(
i).real().normalize();
355 m_eivec.col(
i).imag().setConstant(0);
367 b = mT.diagonal().coeff(
i+1);
377 m_alphas.coeffRef(
i+1) =
alpha;
379 if (computeEigenvectors) {
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()
402 m_eivec.col(
i+1).noalias() = (m_realQZ.matrixZ().transpose() * cv);
403 m_eivec.col(
i+1).normalize();
404 m_eivec.col(
i) = m_eivec.col(
i+1).conjugate();
411 m_vectorsOkay = computeEigenvectors;
418 #endif // EIGEN_GENERALIZEDEIGENSOLVER_H
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
ComplexVectorType alphas() const
Namespace containing all symbols from the Eigen library.
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > ComplexVectorType
Type for vector of complex scalar values eigenvalues as returned by alphas().
Computes the generalized eigenvalues and eigenvectors of a pair of general matrices.
RealQZ< MatrixType > m_realQZ
std::complex< RealScalar > ComplexScalar
Complex scalar type for MatrixType.
static void check_template_parameters()
GeneralizedEigenSolver & compute(const MatrixType &A, const MatrixType &B, bool computeEigenvectors=true)
Computes generalized eigendecomposition of given matrix.
ComputationInfo info() const
MatrixType::Scalar Scalar
Scalar type for matrices of type MatrixType.
m block< 2, Dynamic >(1, 1, 2, 3).setZero()
double beta(double a, double b)
NumTraits< Scalar >::Real RealScalar
EigenvectorsType eigenvectors() const
GeneralizedEigenSolver & setMaxIterations(Index maxIters)
Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > EigenvectorsType
Type for matrix of eigenvectors as returned by eigenvectors().
RealQZ & setMaxIterations(Index maxIters)
GeneralizedEigenSolver(Index size)
Default constructor with memory preallocation.
GeneralizedEigenSolver()
Default constructor.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
A matrix or vector expression mapping an existing array of data.
CwiseBinaryOp< internal::scalar_quotient_op< ComplexScalar, Scalar >, ComplexVectorType, VectorType > EigenvalueType
Expression type for the eigenvalues as returned by eigenvalues().
const AutoDiffScalar< DerType > & real(const AutoDiffScalar< DerType > &x)
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
_MatrixType MatrixType
Synonym for the template parameter _MatrixType.
Array< int, Dynamic, 1 > v
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
EigenvalueType eigenvalues() const
Returns an expression of the computed generalized eigenvalues.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Jet< T, N > sqrt(const Jet< T, N > &f)
GeneralizedEigenSolver(const MatrixType &A, const MatrixType &B, bool computeEigenvectors=true)
Constructor; computes the generalized eigendecomposition of given matrix pair.
ComputationInfo info() const
Reports whether previous computation was successful.
ComplexVectorType m_alphas
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > VectorType
Type for vector of real scalar values eigenvalues as returned by betas().
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:34