11 #ifndef EIGEN_REAL_SCHUR_H 12 #define EIGEN_REAL_SCHUR_H 65 typedef typename MatrixType::Scalar
Scalar;
67 typedef typename MatrixType::Index
Index;
103 RealSchur(
const MatrixType& matrix,
bool computeU =
true)
104 :
m_matT(matrix.rows(),matrix.cols()),
105 m_matU(matrix.rows(),matrix.cols()),
187 template<
typename HessMatrixType,
typename OrthMatrixType>
239 void computeShift(Index iu, Index iter, Scalar& exshift, Vector3s& shiftInfo);
240 void initFrancisQRStep(Index il, Index iu,
const Vector3s& shiftInfo, Index& im, Vector3s& firstHouseholderVector);
241 void performFrancisQRStep(Index il, Index im, Index iu,
bool computeU,
const Vector3s& firstHouseholderVector, Scalar* workspace);
245 template<
typename MatrixType>
261 template<
typename MatrixType>
262 template<
typename HessMatrixType,
typename OrthMatrixType>
309 Vector3s firstHouseholderVector(0,0,0), shiftInfo;
312 totalIter = totalIter + 1;
313 if (totalIter > maxIters)
break;
320 if(totalIter <= maxIters)
331 template<
typename MatrixType>
339 for (
Index j = 0; j < size; ++j)
340 norm +=
m_matT.col(j).segment(0, (std::min)(size,j+2)).cwiseAbs().sum();
345 template<
typename MatrixType>
363 template<
typename MatrixType>
374 m_matT.coeffRef(iu,iu) += exshift;
375 m_matT.coeffRef(iu-1,iu-1) += exshift;
386 m_matT.rightCols(size-iu+1).applyOnTheLeft(iu-1, iu, rot.
adjoint());
387 m_matT.topRows(iu+1).applyOnTheRight(iu-1, iu, rot);
390 m_matU.applyOnTheRight(iu-1, iu, rot);
398 template<
typename MatrixType>
410 exshift += shiftInfo.
coeff(0);
411 for (
Index i = 0; i <= iu; ++i)
423 s = s * s + shiftInfo.
coeff(2);
430 s = shiftInfo.
coeff(0) - shiftInfo.
coeff(2) / s;
432 for (
Index i = 0; i <= iu; ++i)
433 m_matT.coeffRef(i,i) -= s;
440 template<
typename MatrixType>
446 for (im = iu-2; im >= il; --im)
467 template<
typename MatrixType>
475 for (
Index k = im; k <= iu-2; ++k)
477 bool firstIteration = (k == im);
481 v = firstHouseholderVector;
483 v =
m_matT.template block<3,1>(k,k-1);
487 v.makeHouseholder(ess, tau, beta);
491 if (firstIteration && k > il)
493 else if (!firstIteration)
494 m_matT.coeffRef(k,k-1) = beta;
497 m_matT.block(k, k, 3, size-k).applyHouseholderOnTheLeft(ess, tau, workspace);
498 m_matT.block(0, k, (std::min)(iu,k+3) + 1, 3).applyHouseholderOnTheRight(ess, tau, workspace);
500 m_matU.block(0, k, size, 3).applyHouseholderOnTheRight(ess, tau, workspace);
507 v.makeHouseholder(ess, tau, beta);
511 m_matT.coeffRef(iu-1, iu-2) = beta;
512 m_matT.block(iu-1, iu-1, 2, size-iu+1).applyHouseholderOnTheLeft(ess, tau, workspace);
513 m_matT.block(0, iu-1, iu+1, 2).applyHouseholderOnTheRight(ess, tau, workspace);
515 m_matU.block(0, iu-1, size, 2).applyHouseholderOnTheRight(ess, tau, workspace);
519 for (
Index i = im+2; i <= iu; ++i)
529 #endif // EIGEN_REAL_SCHUR_H
HouseholderSequenceType matrixQ() const
Reconstructs the orthogonal matrix Q in the decomposition.
IntermediateState sqrt(const Expression &arg)
MatrixHReturnType matrixH() const
Constructs the Hessenberg matrix H in the decomposition.
Performs a real Schur decomposition of a square matrix.
RealSchur(const MatrixType &matrix, bool computeU=true)
Constructor; computes real Schur decomposition of given matrix.
void makeGivens(const Scalar &p, const Scalar &q, Scalar *z=0)
RealSchur & computeFromHessenberg(const HessMatrixType &matrixH, const OrthMatrixType &matrixQ, bool computeU)
Computes Schur decomposition of a Hessenberg matrix H = Z T Z^T.
const MatrixType & matrixU() const
Returns the orthogonal matrix in the Schur decomposition.
iterative scaling algorithm to equilibrate rows and column norms in matrices
Rotation given by a cosine-sine pair.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
ComputationInfo info() const
Reports whether previous computation was successful.
const MatrixType & matrixT() const
Returns the quasi-triangular matrix in the Schur decomposition.
Index findSmallSubdiagEntry(Index iu, const Scalar &norm)
void computeShift(Index iu, Index iter, Scalar &exshift, Vector3s &shiftInfo)
Index getMaxIterations()
Returns the maximum number of iterations.
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs_op< Scalar >, const Derived > abs() const
HessenbergDecomposition< MatrixType > m_hess
EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
HessenbergDecomposition & compute(const MatrixType &matrix)
Computes Hessenberg decomposition of given matrix.
MatrixType::Scalar Scalar
Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > EigenvalueType
EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
EIGEN_STRONG_INLINE void resize(Index nbRows, Index nbCols)
static const int m_maxIterationsPerRow
Maximum number of iterations per row.
Provides a generic way to set and pass user-specified options.
JacobiRotation adjoint() const
void performFrancisQRStep(Index il, Index im, Index iu, bool computeU, const Vector3s &firstHouseholderVector, Scalar *workspace)
Derived & setConstant(Index size, const Scalar &value)
RealSchur & compute(const MatrixType &matrix, bool computeU=true)
Computes Schur decomposition of given matrix.
void rhs(const real_t *x, real_t *f)
Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > ColumnVectorType
Matrix< Scalar, 3, 1 > Vector3s
RealSchur(Index size=RowsAtCompileTime==Dynamic?1:RowsAtCompileTime)
Default constructor.
RealSchur & setMaxIterations(Index maxIters)
Sets the maximum number of iterations allowed.
void initFrancisQRStep(Index il, Index iu, const Vector3s &shiftInfo, Index &im, Vector3s &firstHouseholderVector)
void splitOffTwoRows(Index iu, bool computeU, const Scalar &exshift)
std::complex< typename NumTraits< Scalar >::Real > ComplexScalar
ColumnVectorType m_workspaceVector