Eigen::ComplexSchur< MatrixType_ > Class Template Reference

Performs a complex Schur decomposition of a real or complex square matrix. More...

#include <ComplexSchur.h>

Public Types

enum  {
  RowsAtCompileTime = MatrixType::RowsAtCompileTime , ColsAtCompileTime = MatrixType::ColsAtCompileTime , Options = internal::traits<MatrixType>::Options , MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime ,
  MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
}
 
typedef MatrixType_ MatrixType
 
typedef MatrixType::Scalar Scalar
 Scalar type for matrices of type MatrixType_. More...
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef Eigen::Index Index
 
typedef std::complex< RealScalarComplexScalar
 Complex scalar type for MatrixType_. More...
 
typedef Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTimeComplexMatrixType
 Type for the matrices in the Schur decomposition. More...
 

Public Member Functions

 ComplexSchur (Index size=RowsAtCompileTime==Dynamic ? 1 :RowsAtCompileTime)
 Default constructor. More...
 
template<typename InputType >
 ComplexSchur (const EigenBase< InputType > &matrix, bool computeU=true)
 Constructor; computes Schur decomposition of given matrix. More...
 
const ComplexMatrixTypematrixU () const
 Returns the unitary matrix in the Schur decomposition. More...
 
const ComplexMatrixTypematrixT () const
 Returns the triangular matrix in the Schur decomposition. More...
 
template<typename InputType >
ComplexSchurcompute (const EigenBase< InputType > &matrix, bool computeU=true)
 Computes Schur decomposition of given matrix. More...
 
template<typename HessMatrixType , typename OrthMatrixType >
ComplexSchurcomputeFromHessenberg (const HessMatrixType &matrixH, const OrthMatrixType &matrixQ, bool computeU=true)
 Compute Schur decomposition from a given Hessenberg matrix. More...
 
ComputationInfo info () const
 Reports whether previous computation was successful. More...
 
ComplexSchursetMaxIterations (Index maxIters)
 Sets the maximum number of iterations allowed. More...
 
Index getMaxIterations ()
 Returns the maximum number of iterations. More...
 
template<typename InputType >
ComplexSchur< MatrixType > & compute (const EigenBase< InputType > &matrix, bool computeU)
 
template<typename HessMatrixType , typename OrthMatrixType >
ComplexSchur< MatrixType > & computeFromHessenberg (const HessMatrixType &matrixH, const OrthMatrixType &matrixQ, bool computeU)
 

Static Public Attributes

static const int m_maxIterationsPerRow = 30
 Maximum number of iterations per row. More...
 

Protected Attributes

ComplexMatrixType m_matT
 
ComplexMatrixType m_matU
 
HessenbergDecomposition< MatrixTypem_hess
 
ComputationInfo m_info
 
bool m_isInitialized
 
bool m_matUisUptodate
 
Index m_maxIters
 

Private Member Functions

bool subdiagonalEntryIsNeglegible (Index i)
 
ComplexScalar computeShift (Index iu, Index iter)
 
void reduceToTriangularForm (bool computeU)
 

Friends

struct internal::complex_schur_reduce_to_hessenberg< MatrixType, NumTraits< Scalar >::IsComplex >
 

Detailed Description

template<typename MatrixType_>
class Eigen::ComplexSchur< MatrixType_ >

Performs a complex Schur decomposition of a real or complex square matrix.

\eigenvalues_module

Template Parameters
MatrixType_the type of the matrix of which we are computing the Schur decomposition; this is expected to be an instantiation of the Matrix class template.

Given a real or complex square matrix A, this class computes the Schur decomposition: \( A = U T U^*\) where U is a unitary complex matrix, and T is a complex upper triangular matrix. The diagonal of the matrix T corresponds to the eigenvalues of the matrix A.

Call the function compute() to compute the Schur decomposition of a given matrix. Alternatively, you can use the ComplexSchur(const MatrixType&, bool) constructor which computes the Schur decomposition at construction time. Once the decomposition is computed, you can use the matrixU() and matrixT() functions to retrieve the matrices U and V in the decomposition.

Note
This code is inspired from Jampack
See also
class RealSchur, class EigenSolver, class ComplexEigenSolver

Member Typedef Documentation

◆ ComplexMatrixType

Type for the matrices in the Schur decomposition.

This is a square matrix with entries of type ComplexScalar. The size is the same as the size of MatrixType_.

◆ ComplexScalar

template<typename MatrixType_ >
typedef std::complex<RealScalar> Eigen::ComplexSchur< MatrixType_ >::ComplexScalar

Complex scalar type for MatrixType_.

This is std::complex<Scalar> if Scalar is real (e.g., float or double) and just Scalar if Scalar is complex.

◆ Index

template<typename MatrixType_ >
typedef Eigen::Index Eigen::ComplexSchur< MatrixType_ >::Index
Deprecated:
since Eigen 3.3

◆ MatrixType

template<typename MatrixType_ >
typedef MatrixType_ Eigen::ComplexSchur< MatrixType_ >::MatrixType

◆ RealScalar

template<typename MatrixType_ >
typedef NumTraits<Scalar>::Real Eigen::ComplexSchur< MatrixType_ >::RealScalar

◆ Scalar

template<typename MatrixType_ >
typedef MatrixType::Scalar Eigen::ComplexSchur< MatrixType_ >::Scalar

Scalar type for matrices of type MatrixType_.

Member Enumeration Documentation

◆ anonymous enum

template<typename MatrixType_ >
anonymous enum
Enumerator
RowsAtCompileTime 
ColsAtCompileTime 
Options 
MaxRowsAtCompileTime 
MaxColsAtCompileTime 
59  {
60  RowsAtCompileTime = MatrixType::RowsAtCompileTime,
61  ColsAtCompileTime = MatrixType::ColsAtCompileTime,
62  Options = internal::traits<MatrixType>::Options,
63  MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
64  MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
65  };
@ MaxRowsAtCompileTime
Definition: ComplexSchur.h:63
@ Options
Definition: ComplexSchur.h:62
@ ColsAtCompileTime
Definition: ComplexSchur.h:61
@ MaxColsAtCompileTime
Definition: ComplexSchur.h:64
@ RowsAtCompileTime
Definition: ComplexSchur.h:60

Constructor & Destructor Documentation

◆ ComplexSchur() [1/2]

template<typename MatrixType_ >
Eigen::ComplexSchur< MatrixType_ >::ComplexSchur ( Index  size = RowsAtCompileTime == Dynamic ? 1 : RowsAtCompileTime)
inlineexplicit

Default constructor.

Parameters
[in]sizePositive integer, size of the matrix whose Schur decomposition will be computed.

The default constructor is useful in cases in which the user intends to perform decompositions via compute(). The size parameter is only used as a hint. It is not an error to give a wrong size, but it may impair performance.

See also
compute() for an example.
101  : m_matT(size, size),
102  m_matU(size, size),
103  m_hess(size),
104  m_isInitialized(false),
105  m_matUisUptodate(false),
106  m_maxIters(-1) {}
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
bool m_matUisUptodate
Definition: ComplexSchur.h:250
bool m_isInitialized
Definition: ComplexSchur.h:249
HessenbergDecomposition< MatrixType > m_hess
Definition: ComplexSchur.h:247
ComplexMatrixType m_matU
Definition: ComplexSchur.h:246
ComplexMatrixType m_matT
Definition: ComplexSchur.h:246
Index m_maxIters
Definition: ComplexSchur.h:251

◆ ComplexSchur() [2/2]

template<typename MatrixType_ >
template<typename InputType >
Eigen::ComplexSchur< MatrixType_ >::ComplexSchur ( const EigenBase< InputType > &  matrix,
bool  computeU = true 
)
inlineexplicit

Constructor; computes Schur decomposition of given matrix.

Parameters
[in]matrixSquare matrix whose Schur decomposition is to be computed.
[in]computeUIf true, both T and U are computed; if false, only T is computed.

This constructor calls compute() to compute the Schur decomposition.

See also
matrixT() and matrixU() for examples.
119  : m_matT(matrix.rows(), matrix.cols()),
120  m_matU(matrix.rows(), matrix.cols()),
121  m_hess(matrix.rows()),
122  m_isInitialized(false),
123  m_matUisUptodate(false),
124  m_maxIters(-1) {
125  compute(matrix.derived(), computeU);
126  }
ComplexSchur & compute(const EigenBase< InputType > &matrix, bool computeU=true)
Computes Schur decomposition of given matrix.
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor >, 0, Eigen::OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: common.h:85

References Eigen::ComplexSchur< MatrixType_ >::compute(), and matrix().

Member Function Documentation

◆ compute() [1/2]

template<typename MatrixType_ >
template<typename InputType >
ComplexSchur<MatrixType>& Eigen::ComplexSchur< MatrixType_ >::compute ( const EigenBase< InputType > &  matrix,
bool  computeU 
)
314  {
315  m_matUisUptodate = false;
316  eigen_assert(matrix.cols() == matrix.rows());
317 
318  if (matrix.cols() == 1) {
319  m_matT = matrix.derived().template cast<ComplexScalar>();
320  if (computeU) m_matU = ComplexMatrixType::Identity(1, 1);
321  m_info = Success;
322  m_isInitialized = true;
323  m_matUisUptodate = computeU;
324  return *this;
325  }
326 
328  computeU);
329  computeFromHessenberg(m_matT, m_matU, computeU);
330  return *this;
331 }
#define eigen_assert(x)
Definition: Macros.h:910
ComplexSchur & computeFromHessenberg(const HessMatrixType &matrixH, const OrthMatrixType &matrixQ, bool computeU=true)
Compute Schur decomposition from a given Hessenberg matrix.
ComputationInfo m_info
Definition: ComplexSchur.h:248
@ IsComplex
Definition: common.h:73
@ Success
Definition: Constants.h:440
auto run(Kernel kernel, Args &&... args) -> decltype(kernel(args...))
Definition: gpu_test_helper.h:414

References Eigen::ComplexSchur< MatrixType_ >::computeFromHessenberg(), eigen_assert, Eigen::ComplexSchur< MatrixType_ >::m_info, Eigen::ComplexSchur< MatrixType_ >::m_isInitialized, Eigen::ComplexSchur< MatrixType_ >::m_matT, Eigen::ComplexSchur< MatrixType_ >::m_matU, Eigen::ComplexSchur< MatrixType_ >::m_matUisUptodate, matrix(), Eigen::run(), and Eigen::Success.

◆ compute() [2/2]

template<typename MatrixType_ >
template<typename InputType >
ComplexSchur& Eigen::ComplexSchur< MatrixType_ >::compute ( const EigenBase< InputType > &  matrix,
bool  computeU = true 
)

Computes Schur decomposition of given matrix.

Parameters
[in]matrixSquare matrix whose Schur decomposition is to be computed.
[in]computeUIf true, both T and U are computed; if false, only T is computed.
Returns
Reference to *this

The Schur decomposition is computed by first reducing the matrix to Hessenberg form using the class HessenbergDecomposition. The Hessenberg matrix is then reduced to triangular form by performing QR iterations with a single shift. The cost of computing the Schur decomposition depends on the number of iterations; as a rough guide, it may be taken on the number of iterations; as a rough guide, it may be taken to be \(25n^3\) complex flops, or \(10n^3\) complex flops if computeU is false.

Example:

MatrixXcf A = MatrixXcf::Random(4, 4);
ComplexSchur<MatrixXcf> schur(4);
schur.compute(A);
cout << "The matrix T in the decomposition of A is:" << endl << schur.matrixT() << endl;
schur.compute(A.inverse());
cout << "The matrix T in the decomposition of A^(-1) is:" << endl << schur.matrixT() << endl;
ComplexSchur< MatrixXcf > schur(4)
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47

Output:

See also
compute(const MatrixType&, bool, Index)

Referenced by Eigen::ComplexSchur< MatrixType_ >::ComplexSchur(), Eigen::ComplexEigenSolver< MatrixType_ >::compute(), ctms_decompositions(), and schur().

◆ computeFromHessenberg() [1/2]

template<typename MatrixType_ >
template<typename HessMatrixType , typename OrthMatrixType >
ComplexSchur<MatrixType>& Eigen::ComplexSchur< MatrixType_ >::computeFromHessenberg ( const HessMatrixType &  matrixH,
const OrthMatrixType &  matrixQ,
bool  computeU 
)
337  {
338  m_matT = matrixH;
339  if (computeU) m_matU = matrixQ;
340  reduceToTriangularForm(computeU);
341  return *this;
342 }
void reduceToTriangularForm(bool computeU)
Definition: ComplexSchur.h:376

References Eigen::ComplexSchur< MatrixType_ >::m_matT, Eigen::ComplexSchur< MatrixType_ >::m_matU, and Eigen::ComplexSchur< MatrixType_ >::reduceToTriangularForm().

◆ computeFromHessenberg() [2/2]

template<typename MatrixType_ >
template<typename HessMatrixType , typename OrthMatrixType >
ComplexSchur& Eigen::ComplexSchur< MatrixType_ >::computeFromHessenberg ( const HessMatrixType &  matrixH,
const OrthMatrixType &  matrixQ,
bool  computeU = true 
)

Compute Schur decomposition from a given Hessenberg matrix.

Parameters
[in]matrixHMatrix in Hessenberg form H
[in]matrixQorthogonal matrix Q that transform a matrix A to H : A = Q H Q^T
computeUComputes the matriX U of the Schur vectors
Returns
Reference to *this

This routine assumes that the matrix is already reduced in Hessenberg form matrixH using either the class HessenbergDecomposition or another mean. It computes the upper quasi-triangular matrix T of the Schur decomposition of H When computeU is true, this routine computes the matrix U such that A = U T U^T = (QZ) T (QZ)^T = Q H Q^T where A is the initial matrix

NOTE Q is referenced if computeU is true; so, if the initial orthogonal matrix is not available, the user should give an identity matrix (Q.setIdentity())

See also
compute(const MatrixType&, bool)

Referenced by Eigen::ComplexSchur< MatrixType_ >::compute().

◆ computeShift()

template<typename MatrixType >
ComplexSchur< MatrixType >::ComplexScalar Eigen::ComplexSchur< MatrixType >::computeShift ( Index  iu,
Index  iter 
)
private

Compute the shift in the current QR iteration.

276  {
277  using std::abs;
278  if ((iter == 10 || iter == 20) && iu > 1) {
279  // exceptional shift, taken from http://www.netlib.org/eispack/comqr.f
280  return abs(numext::real(m_matT.coeff(iu, iu - 1))) + abs(numext::real(m_matT.coeff(iu - 1, iu - 2)));
281  }
282 
283  // compute the shift as one of the eigenvalues of t, the 2x2
284  // diagonal block on the bottom of the active submatrix
285  Matrix<ComplexScalar, 2, 2> t = m_matT.template block<2, 2>(iu - 1, iu - 1);
286  RealScalar normt = t.cwiseAbs().sum();
287  t /= normt; // the normalization by sf is to avoid under/overflow
288 
289  ComplexScalar b = t.coeff(0, 1) * t.coeff(1, 0);
290  ComplexScalar c = t.coeff(0, 0) - t.coeff(1, 1);
291  ComplexScalar disc = sqrt(c * c + RealScalar(4) * b);
292  ComplexScalar det = t.coeff(0, 0) * t.coeff(1, 1) - b;
293  ComplexScalar trace = t.coeff(0, 0) + t.coeff(1, 1);
294  ComplexScalar eival1 = (trace + disc) / RealScalar(2);
295  ComplexScalar eival2 = (trace - disc) / RealScalar(2);
296  RealScalar eival1_norm = numext::norm1(eival1);
297  RealScalar eival2_norm = numext::norm1(eival2);
298  // A division by zero can only occur if eival1==eival2==0.
299  // In this case, det==0, and all we have to do is checking that eival2_norm!=0
300  if (eival1_norm > eival2_norm)
301  eival2 = det / eival1;
302  else if (!numext::is_exactly_zero(eival2_norm))
303  eival1 = det / eival2;
304 
305  // choose the eigenvalue closest to the bottom entry of the diagonal
306  if (numext::norm1(eival1 - t.coeff(1, 1)) < numext::norm1(eival2 - t.coeff(1, 1)))
307  return normt * eival1;
308  else
309  return normt * eival2;
310 }
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
Scalar * b
Definition: benchVecAdd.cpp:17
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
NumTraits< Scalar >::Real RealScalar
Definition: ComplexSchur.h:69
std::complex< RealScalar > ComplexScalar
Complex scalar type for MatrixType_.
Definition: ComplexSchur.h:78
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:198
float real
Definition: datatypes.h:10
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool is_exactly_zero(const X &x)
Definition: Meta.h:592
int c
Definition: calibrate.py:100
t
Definition: plotPSD.py:36

References abs(), b, calibrate::c, Eigen::PlainObjectBase< Derived >::coeff(), Eigen::numext::is_exactly_zero(), Eigen::ComplexSchur< MatrixType_ >::m_matT, sqrt(), and plotPSD::t.

Referenced by Eigen::ComplexSchur< MatrixType_ >::reduceToTriangularForm().

◆ getMaxIterations()

template<typename MatrixType_ >
Index Eigen::ComplexSchur< MatrixType_ >::getMaxIterations ( )
inline

Returns the maximum number of iterations.

236 { return m_maxIters; }

References Eigen::ComplexSchur< MatrixType_ >::m_maxIters.

Referenced by Eigen::ComplexEigenSolver< MatrixType_ >::getMaxIterations(), and schur().

◆ info()

template<typename MatrixType_ >
ComputationInfo Eigen::ComplexSchur< MatrixType_ >::info ( ) const
inline

Reports whether previous computation was successful.

Returns
Success if computation was successful, NoConvergence otherwise.
220  {
221  eigen_assert(m_isInitialized && "ComplexSchur is not initialized.");
222  return m_info;
223  }

References eigen_assert, Eigen::ComplexSchur< MatrixType_ >::m_info, and Eigen::ComplexSchur< MatrixType_ >::m_isInitialized.

Referenced by Eigen::ComplexEigenSolver< MatrixType_ >::compute(), Eigen::ComplexEigenSolver< MatrixType_ >::info(), and schur().

◆ matrixT()

template<typename MatrixType_ >
const ComplexMatrixType& Eigen::ComplexSchur< MatrixType_ >::matrixT ( ) const
inline

Returns the triangular matrix in the Schur decomposition.

Returns
A const reference to the matrix T.

It is assumed that either the constructor ComplexSchur(const MatrixType& matrix, bool computeU) or the member function compute(const MatrixType& matrix, bool computeU) has been called before to compute the Schur decomposition of a matrix.

Note that this function returns a plain square matrix. If you want to reference only the upper triangular part, use:

schur.matrixT().triangularView<Upper>()
@ Upper
Definition: Constants.h:213

Example:

MatrixXcf A = MatrixXcf::Random(4, 4);
cout << "Here is a random 4x4 matrix, A:" << endl << A << endl << endl;
ComplexSchur<MatrixXcf> schurOfA(A, false); // false means do not compute U
cout << "The triangular matrix T is:" << endl << schurOfA.matrixT() << endl;
cout<< "Here is a random 4x4 matrix, A:"<< endl<< A<< endl<< endl;ComplexSchur< MatrixXcf > schurOfA(A, false)

Output:

 
165  {
166  eigen_assert(m_isInitialized && "ComplexSchur is not initialized.");
167  return m_matT;
168  }

References eigen_assert, Eigen::ComplexSchur< MatrixType_ >::m_isInitialized, and Eigen::ComplexSchur< MatrixType_ >::m_matT.

Referenced by Eigen::ComplexEigenSolver< MatrixType_ >::compute(), Eigen::ComplexEigenSolver< MatrixType_ >::doComputeEigenvectors(), schur(), and Eigen::DGMRES< MatrixType_, Preconditioner_ >::schurValues().

◆ matrixU()

template<typename MatrixType_ >
const ComplexMatrixType& Eigen::ComplexSchur< MatrixType_ >::matrixU ( ) const
inline

Returns the unitary matrix in the Schur decomposition.

Returns
A const reference to the matrix U.

It is assumed that either the constructor ComplexSchur(const MatrixType& matrix, bool computeU) or the member function compute(const MatrixType& matrix, bool computeU) has been called before to compute the Schur decomposition of a matrix, and that computeU was set to true (the default value).

Example:

MatrixXcf A = MatrixXcf::Random(4, 4);
cout << "Here is a random 4x4 matrix, A:" << endl << A << endl << endl;
ComplexSchur<MatrixXcf> schurOfA(A);
cout << "The unitary matrix U is:" << endl << schurOfA.matrixU() << endl;

Output:

 
142  {
143  eigen_assert(m_isInitialized && "ComplexSchur is not initialized.");
144  eigen_assert(m_matUisUptodate && "The matrix U has not been computed during the ComplexSchur decomposition.");
145  return m_matU;
146  }

References eigen_assert, Eigen::ComplexSchur< MatrixType_ >::m_isInitialized, Eigen::ComplexSchur< MatrixType_ >::m_matU, and Eigen::ComplexSchur< MatrixType_ >::m_matUisUptodate.

Referenced by Eigen::ComplexEigenSolver< MatrixType_ >::doComputeEigenvectors(), and schur().

◆ reduceToTriangularForm()

template<typename MatrixType >
void Eigen::ComplexSchur< MatrixType >::reduceToTriangularForm ( bool  computeU)
private
376  {
377  Index maxIters = m_maxIters;
378  if (maxIters == -1) maxIters = m_maxIterationsPerRow * m_matT.rows();
379 
380  // The matrix m_matT is divided in three parts.
381  // Rows 0,...,il-1 are decoupled from the rest because m_matT(il,il-1) is zero.
382  // Rows il,...,iu is the part we are working on (the active submatrix).
383  // Rows iu+1,...,end are already brought in triangular form.
384  Index iu = m_matT.cols() - 1;
385  Index il;
386  Index iter = 0; // number of iterations we are working on the (iu,iu) element
387  Index totalIter = 0; // number of iterations for whole matrix
388 
389  while (true) {
390  // find iu, the bottom row of the active submatrix
391  while (iu > 0) {
392  if (!subdiagonalEntryIsNeglegible(iu - 1)) break;
393  iter = 0;
394  --iu;
395  }
396 
397  // if iu is zero then we are done; the whole matrix is triangularized
398  if (iu == 0) break;
399 
400  // if we spent too many iterations, we give up
401  iter++;
402  totalIter++;
403  if (totalIter > maxIters) break;
404 
405  // find il, the top row of the active submatrix
406  il = iu - 1;
407  while (il > 0 && !subdiagonalEntryIsNeglegible(il - 1)) {
408  --il;
409  }
410 
411  /* perform the QR step using Givens rotations. The first rotation
412  creates a bulge; the (il+2,il) element becomes nonzero. This
413  bulge is chased down to the bottom of the active submatrix. */
414 
415  ComplexScalar shift = computeShift(iu, iter);
416  JacobiRotation<ComplexScalar> rot;
417  rot.makeGivens(m_matT.coeff(il, il) - shift, m_matT.coeff(il + 1, il));
418  m_matT.rightCols(m_matT.cols() - il).applyOnTheLeft(il, il + 1, rot.adjoint());
419  m_matT.topRows((std::min)(il + 2, iu) + 1).applyOnTheRight(il, il + 1, rot);
420  if (computeU) m_matU.applyOnTheRight(il, il + 1, rot);
421 
422  for (Index i = il + 1; i < iu; i++) {
423  rot.makeGivens(m_matT.coeffRef(i, i - 1), m_matT.coeffRef(i + 1, i - 1), &m_matT.coeffRef(i, i - 1));
424  m_matT.coeffRef(i + 1, i - 1) = ComplexScalar(0);
425  m_matT.rightCols(m_matT.cols() - i).applyOnTheLeft(i, i + 1, rot.adjoint());
426  m_matT.topRows((std::min)(i + 2, iu) + 1).applyOnTheRight(i, i + 1, rot);
427  if (computeU) m_matU.applyOnTheRight(i, i + 1, rot);
428  }
429  }
430 
431  if (totalIter <= maxIters)
432  m_info = Success;
433  else
435 
436  m_isInitialized = true;
437  m_matUisUptodate = computeU;
438 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
static const int m_maxIterationsPerRow
Maximum number of iterations per row.
Definition: ComplexSchur.h:243
Eigen::Index Index
Definition: ComplexSchur.h:70
bool subdiagonalEntryIsNeglegible(Index i)
Definition: ComplexSchur.h:264
ComplexScalar computeShift(Index iu, Index iter)
Definition: ComplexSchur.h:276
EIGEN_DEVICE_FUNC constexpr EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
Definition: PlainObjectBase.h:217
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:192
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:191
#define min(a, b)
Definition: datatypes.h:22
@ NoConvergence
Definition: Constants.h:444
EIGEN_BLAS_FUNC() rot(int *n, Scalar *px, int *incx, Scalar *py, int *incy, Scalar *pc, Scalar *ps)
Definition: level1_real_impl.h:88

References Eigen::PlainObjectBase< Derived >::coeff(), Eigen::Matrix< Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_ >::coeffRef(), Eigen::PlainObjectBase< Derived >::cols(), Eigen::ComplexSchur< MatrixType_ >::computeShift(), i, Eigen::ComplexSchur< MatrixType_ >::m_info, Eigen::ComplexSchur< MatrixType_ >::m_isInitialized, Eigen::ComplexSchur< MatrixType_ >::m_matT, Eigen::ComplexSchur< MatrixType_ >::m_matU, Eigen::ComplexSchur< MatrixType_ >::m_matUisUptodate, Eigen::ComplexSchur< MatrixType_ >::m_maxIterationsPerRow, Eigen::ComplexSchur< MatrixType_ >::m_maxIters, min, Eigen::NoConvergence, rot(), Eigen::PlainObjectBase< Derived >::rows(), Eigen::ComplexSchur< MatrixType_ >::subdiagonalEntryIsNeglegible(), and Eigen::Success.

Referenced by Eigen::ComplexSchur< MatrixType_ >::computeFromHessenberg().

◆ setMaxIterations()

template<typename MatrixType_ >
ComplexSchur& Eigen::ComplexSchur< MatrixType_ >::setMaxIterations ( Index  maxIters)
inline

Sets the maximum number of iterations allowed.

If not specified by the user, the maximum number of iterations is m_maxIterationsPerRow times the size of the matrix.

230  {
231  m_maxIters = maxIters;
232  return *this;
233  }

References Eigen::ComplexSchur< MatrixType_ >::m_maxIters.

Referenced by schur(), and Eigen::ComplexEigenSolver< MatrixType_ >::setMaxIterations().

◆ subdiagonalEntryIsNeglegible()

template<typename MatrixType >
bool Eigen::ComplexSchur< MatrixType >::subdiagonalEntryIsNeglegible ( Index  i)
inlineprivate

If m_matT(i+1,i) is negligible in floating point arithmetic compared to m_matT(i,i) and m_matT(j,j), then set it to zero and return true, else return false.

264  {
265  RealScalar d = numext::norm1(m_matT.coeff(i, i)) + numext::norm1(m_matT.coeff(i + 1, i + 1));
266  RealScalar sd = numext::norm1(m_matT.coeff(i + 1, i));
268  m_matT.coeffRef(i + 1, i) = ComplexScalar(0);
269  return true;
270  }
271  return false;
272 }
EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Definition: MathFunctions.h:1916
double epsilon
Definition: osc_ring_sarah_asymptotics.h:43

References Eigen::PlainObjectBase< Derived >::coeff(), Eigen::Matrix< Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_ >::coeffRef(), i, Eigen::internal::isMuchSmallerThan(), and Eigen::ComplexSchur< MatrixType_ >::m_matT.

Referenced by Eigen::ComplexSchur< MatrixType_ >::reduceToTriangularForm().

Friends And Related Function Documentation

◆ internal::complex_schur_reduce_to_hessenberg< MatrixType, NumTraits< Scalar >::IsComplex >

template<typename MatrixType_ >
friend struct internal::complex_schur_reduce_to_hessenberg< MatrixType, NumTraits< Scalar >::IsComplex >
friend

Member Data Documentation

◆ m_hess

◆ m_info

◆ m_isInitialized

◆ m_matT

◆ m_matU

◆ m_matUisUptodate

◆ m_maxIterationsPerRow

template<typename MatrixType_ >
const int Eigen::ComplexSchur< MatrixType_ >::m_maxIterationsPerRow = 30
static

Maximum number of iterations per row.

If not otherwise specified, the maximum number of iterations is this number times the size of the matrix. It is currently set to 30.

Referenced by Eigen::ComplexSchur< MatrixType_ >::reduceToTriangularForm().

◆ m_maxIters


The documentation for this class was generated from the following file: