12#ifndef EIGEN_GENERALIZEDEIGENSOLVER_H
13#define EIGEN_GENERALIZEDEIGENSOLVER_H
74 typedef typename MatrixType::Scalar
Scalar;
285template<
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)
330 if(
abs(m_betas.coeffRef(
i)) >= (std::numeric_limits<RealScalar>::min)())
334 const Scalar beta = m_betas.coeffRef(
i);
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);
368 const RealScalar beta = m_betas.coeffRef(
i) = m_betas.coeffRef(
i+1) =
a*
b;
377 m_alphas.coeffRef(
i+1) =
alpha;
379 if (computeEigenvectors) {
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)));
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;
ArrayXXi a
Definition Array_initializer_list_23_cxx11.cpp:1
Array< int, Dynamic, 1 > v
Definition Array_initializer_list_vector_cxx11.cpp:1
int i
Definition BiCGSTAB_step_by_step.cpp:9
#define eigen_assert(x)
Definition Macros.h:1037
m block< 2, Dynamic >(1, 1, 2, 3).setZero()
#define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE)
Definition StaticAssert.h:187
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Definition StaticAssert.h:127
float * p
Definition Tutorial_Map_using.cpp:9
int rows
Definition Tutorial_commainit_02.cpp:1
int cols
Definition Tutorial_commainit_02.cpp:1
Scalar * b
Definition benchVecAdd.cpp:17
Scalar Scalar int size
Definition benchVecAdd.cpp:17
SCALAR Scalar
Definition bench_gemm.cpp:46
MatrixXf MatrixType
Definition benchmark-blocking-sizes.cpp:52
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition CwiseBinaryOp.h:84
Computes the generalized eigenvalues and eigenvectors of a pair of general matrices.
Definition GeneralizedEigenSolver.h:59
bool m_valuesOkay
Definition GeneralizedEigenSolver.h:280
bool m_vectorsOkay
Definition GeneralizedEigenSolver.h:280
RealQZ< MatrixType > m_realQZ
Definition GeneralizedEigenSolver.h:281
GeneralizedEigenSolver & compute(const MatrixType &A, const MatrixType &B, bool computeEigenvectors=true)
Computes generalized eigendecomposition of given matrix.
Definition GeneralizedEigenSolver.h:287
GeneralizedEigenSolver(const MatrixType &A, const MatrixType &B, bool computeEigenvectors=true)
Constructor; computes the generalized eigendecomposition of given matrix pair.
Definition GeneralizedEigenSolver.h:155
NumTraits< Scalar >::Real RealScalar
Definition GeneralizedEigenSolver.h:75
EigenvectorsType eigenvectors() const
Definition GeneralizedEigenSolver.h:179
GeneralizedEigenSolver & setMaxIterations(Index maxIters)
Definition GeneralizedEigenSolver.h:263
Eigen::Index Index
Definition GeneralizedEigenSolver.h:76
VectorType m_betas
Definition GeneralizedEigenSolver.h:279
_MatrixType MatrixType
Synonym for the template parameter _MatrixType.
Definition GeneralizedEigenSolver.h:63
Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > VectorType
Type for vector of real scalar values eigenvalues as returned by betas().
Definition GeneralizedEigenSolver.h:91
EigenvalueType eigenvalues() const
Returns an expression of the computed generalized eigenvalues.
Definition GeneralizedEigenSolver.h:202
ComplexVectorType m_tmp
Definition GeneralizedEigenSolver.h:282
ComplexVectorType alphas() const
Definition GeneralizedEigenSolver.h:213
static void check_template_parameters()
Definition GeneralizedEigenSolver.h:271
EigenvectorsType m_eivec
Definition GeneralizedEigenSolver.h:277
GeneralizedEigenSolver(Index size)
Default constructor with memory preallocation.
Definition GeneralizedEigenSolver.h:133
ComputationInfo info() const
Definition GeneralizedEigenSolver.h:255
std::complex< RealScalar > ComplexScalar
Complex scalar type for MatrixType.
Definition GeneralizedEigenSolver.h:84
VectorType betas() const
Definition GeneralizedEigenSolver.h:224
@ Options
Definition GeneralizedEigenSolver.h:68
@ ColsAtCompileTime
Definition GeneralizedEigenSolver.h:67
@ MaxRowsAtCompileTime
Definition GeneralizedEigenSolver.h:69
@ RowsAtCompileTime
Definition GeneralizedEigenSolver.h:66
@ MaxColsAtCompileTime
Definition GeneralizedEigenSolver.h:70
Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > ComplexVectorType
Type for vector of complex scalar values eigenvalues as returned by alphas().
Definition GeneralizedEigenSolver.h:98
CwiseBinaryOp< internal::scalar_quotient_op< ComplexScalar, Scalar >, ComplexVectorType, VectorType > EigenvalueType
Expression type for the eigenvalues as returned by eigenvalues().
Definition GeneralizedEigenSolver.h:102
ComplexVectorType m_alphas
Definition GeneralizedEigenSolver.h:278
GeneralizedEigenSolver()
Default constructor.
Definition GeneralizedEigenSolver.h:118
MatrixType::Scalar Scalar
Scalar type for matrices of type MatrixType.
Definition GeneralizedEigenSolver.h:74
Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > EigenvectorsType
Type for matrix of eigenvectors as returned by eigenvectors().
Definition GeneralizedEigenSolver.h:109
A matrix or vector expression mapping an existing array of data.
Definition Map.h:96
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
Definition PlainObjectBase.h:175
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition PlainObjectBase.h:145
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
Definition PlainObjectBase.h:152
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
Definition CwiseNullaryOp.h:562
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition PlainObjectBase.h:143
Performs a real QZ decomposition of a pair of square matrices.
Definition RealQZ.h:58
ComputationInfo info() const
Reports whether previous computation was successful.
Definition RealQZ.h:169
RealQZ & setMaxIterations(Index maxIters)
Definition RealQZ.h:186
#define abs(x)
Definition datatypes.h:17
ComputationInfo
Definition Constants.h:440
@ Success
Definition Constants.h:442
RealScalar alpha
Definition level1_cplx_impl.h:147
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
Definition AutoDiffScalar.h:574
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:233
std::ptrdiff_t j
Definition tut_arithmetic_redux_minmax.cpp:2