11 #ifndef EIGEN_REAL_SCHUR_H 12 #define EIGEN_REAL_SCHUR_H 65 typedef typename MatrixType::Scalar
Scalar;
103 template<
typename InputType>
105 :
m_matT(matrix.rows(),matrix.cols()),
106 m_matU(matrix.rows(),matrix.cols()),
169 template<
typename InputType>
189 template<
typename HessMatrixType,
typename OrthMatrixType>
241 void computeShift(Index iu, Index iter, Scalar& exshift, Vector3s& shiftInfo);
242 void initFrancisQRStep(Index il, Index iu,
const Vector3s& shiftInfo, Index& im, Vector3s& firstHouseholderVector);
243 void performFrancisQRStep(Index il, Index im, Index iu,
bool computeU,
const Vector3s& firstHouseholderVector, Scalar* workspace);
247 template<
typename MatrixType>
248 template<
typename InputType>
268 template<
typename MatrixType>
269 template<
typename HessMatrixType,
typename OrthMatrixType>
318 Vector3s firstHouseholderVector(0,0,0), shiftInfo;
321 totalIter = totalIter + 1;
322 if (totalIter > maxIters)
break;
329 if(totalIter <= maxIters)
340 template<
typename MatrixType>
348 for (
Index j = 0; j < size; ++j)
349 norm +=
m_matT.col(j).segment(0, (
std::min)(size,j+2)).cwiseAbs().sum();
354 template<
typename MatrixType>
370 template<
typename MatrixType>
381 m_matT.coeffRef(iu,iu) += exshift;
382 m_matT.coeffRef(iu-1,iu-1) += exshift;
393 m_matT.rightCols(size-iu+1).applyOnTheLeft(iu-1, iu, rot.
adjoint());
394 m_matT.topRows(iu+1).applyOnTheRight(iu-1, iu, rot);
397 m_matU.applyOnTheRight(iu-1, iu, rot);
405 template<
typename MatrixType>
417 exshift += shiftInfo.
coeff(0);
418 for (
Index i = 0; i <= iu; ++i)
430 s = s * s + shiftInfo.
coeff(2);
437 s = shiftInfo.
coeff(0) - shiftInfo.
coeff(2) / s;
439 for (
Index i = 0; i <= iu; ++i)
440 m_matT.coeffRef(i,i) -= s;
447 template<
typename MatrixType>
451 Vector3s& v = firstHouseholderVector;
453 for (im = iu-2; im >= il; --im)
472 template<
typename MatrixType>
480 for (
Index k = im; k <= iu-2; ++k)
482 bool firstIteration = (k == im);
486 v = firstHouseholderVector;
488 v =
m_matT.template block<3,1>(k,k-1);
492 v.makeHouseholder(ess, tau, beta);
496 if (firstIteration && k > il)
498 else if (!firstIteration)
499 m_matT.coeffRef(k,k-1) = beta;
502 m_matT.block(k, k, 3, size-k).applyHouseholderOnTheLeft(ess, tau, workspace);
503 m_matT.block(0, k, (
std::min)(iu,k+3) + 1, 3).applyHouseholderOnTheRight(ess, tau, workspace);
505 m_matU.block(0, k, size, 3).applyHouseholderOnTheRight(ess, tau, workspace);
512 v.makeHouseholder(ess, tau, beta);
516 m_matT.coeffRef(iu-1, iu-2) = beta;
517 m_matT.block(iu-1, iu-1, 2, size-iu+1).applyHouseholderOnTheLeft(ess, tau, workspace);
518 m_matT.block(0, iu-1, iu+1, 2).applyHouseholderOnTheRight(ess, tau, workspace);
520 m_matU.block(0, iu-1, size, 2).applyHouseholderOnTheRight(ess, tau, workspace);
524 for (
Index i = im+2; i <= iu; ++i)
534 #endif // EIGEN_REAL_SCHUR_H
Index findSmallSubdiagEntry(Index iu)
EIGEN_DEVICE_FUNC Index rows() const
Performs a real Schur decomposition of a square 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.
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Rotation given by a cosine-sine pair.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
RealSchur(Index size=RowsAtCompileTime==Dynamic ? 1 :RowsAtCompileTime)
Default constructor.
void computeShift(Index iu, Index iter, Scalar &exshift, Vector3s &shiftInfo)
Index getMaxIterations()
Returns the maximum number of iterations.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
HessenbergDecomposition< MatrixType > m_hess
HessenbergDecomposition & compute(const EigenBase< InputType > &matrix)
Computes Hessenberg decomposition of given matrix.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
MatrixHReturnType matrixH() const
Constructs the Hessenberg matrix H in the decomposition.
MatrixType::Scalar Scalar
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > EigenvalueType
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
static const int m_maxIterationsPerRow
Maximum number of iterations per row.
void performFrancisQRStep(Index il, Index im, Index iu, bool computeU, const Vector3s &firstHouseholderVector, Scalar *workspace)
RealSchur & compute(const EigenBase< InputType > &matrix, bool computeU=true)
Computes Schur decomposition of given matrix.
const MatrixType & matrixT() const
Returns the quasi-triangular matrix in the Schur decomposition.
EIGEN_DEVICE_FUNC Derived & setConstant(Index size, const Scalar &val)
Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > ColumnVectorType
Matrix< Scalar, 3, 1 > Vector3s
const MatrixType & matrixU() const
Returns the orthogonal matrix in the Schur decomposition.
RealSchur & setMaxIterations(Index maxIters)
Sets the maximum number of iterations allowed.
EIGEN_DEVICE_FUNC Index cols() const
HouseholderSequenceType matrixQ() const
Reconstructs the orthogonal matrix Q in the decomposition.
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
ComputationInfo info() const
Reports whether previous computation was successful.
ColumnVectorType m_workspaceVector
RealSchur(const EigenBase< InputType > &matrix, bool computeU=true)
Constructor; computes real Schur decomposition of given matrix.
EIGEN_DEVICE_FUNC Derived & derived()
JacobiRotation adjoint() const