12#ifndef EIGEN_COMPLEX_SCHUR_H
13#define EIGEN_COMPLEX_SCHUR_H
20template<
typename MatrixType,
bool IsComplex>
struct complex_schur_reduce_to_hessenberg;
64 typedef typename MatrixType::Scalar
Scalar;
112 template<
typename InputType>
190 template<
typename InputType>
210 template<
typename HessMatrixType,
typename OrthMatrixType>
256 bool subdiagonalEntryIsNeglegible(
Index i);
258 void reduceToTriangularForm(
bool computeU);
265template<typename MatrixType>
266inline bool
ComplexSchur<MatrixType>::subdiagonalEntryIsNeglegible(Index i)
280template<
typename MatrixType>
281typename ComplexSchur<MatrixType>::ComplexScalar ComplexSchur<MatrixType>::computeShift(
Index iu,
Index iter)
284 if (iter == 10 || iter == 20)
292 Matrix<ComplexScalar,2,2> t =
m_matT.template block<2,2>(iu-1,iu-1);
303 RealScalar eival1_norm = numext::norm1(eival1);
304 RealScalar eival2_norm = numext::norm1(eival2);
307 if(eival1_norm > eival2_norm)
308 eival2 = det / eival1;
310 eival1 = det / eival2;
313 if(numext::norm1(eival1-t.coeff(1,1)) < numext::norm1(eival2-t.coeff(1,1)))
314 return normt * eival1;
316 return normt * eival2;
320template<
typename MatrixType>
321template<
typename InputType>
329 m_matT =
matrix.derived().template cast<ComplexScalar>();
330 if(computeU)
m_matU = ComplexMatrixType::Identity(1,1);
342template<
typename MatrixType>
343template<
typename HessMatrixType,
typename OrthMatrixType>
349 reduceToTriangularForm(computeU);
355template<
typename MatrixType,
bool IsComplex>
363 if(computeU)
_this.m_matU =
_this.m_hess.matrixQ();
367template<
typename MatrixType>
389template<
typename MatrixType>
390void ComplexSchur<MatrixType>::reduceToTriangularForm(
bool computeU)
410 if(!subdiagonalEntryIsNeglegible(iu-1))
break;
421 if(totalIter > maxIters)
break;
425 while(il > 0 && !subdiagonalEntryIsNeglegible(il-1))
435 JacobiRotation<ComplexScalar>
rot;
438 m_matT.topRows((std::min)(il+2,iu)+1).applyOnTheRight(il, il+1,
rot);
439 if(computeU)
m_matU.applyOnTheRight(il, il+1,
rot);
446 m_matT.topRows((std::min)(
i+2,iu)+1).applyOnTheRight(
i,
i+1,
rot);
451 if(totalIter <= maxIters)
int i
Definition BiCGSTAB_step_by_step.cpp:9
MatrixXf Q
Definition HouseholderQR_householderQ.cpp:1
#define eigen_assert(x)
Definition Macros.h:1037
int rows
Definition Tutorial_commainit_02.cpp:1
int cols
Definition Tutorial_commainit_02.cpp:1
Scalar Scalar * c
Definition benchVecAdd.cpp:17
Scalar * b
Definition benchVecAdd.cpp:17
Scalar Scalar int size
Definition benchVecAdd.cpp:17
NumTraits< Scalar >::Real RealScalar
Definition bench_gemm.cpp:47
MatrixXf MatrixType
Definition benchmark-blocking-sizes.cpp:52
Performs a complex Schur decomposition of a real or complex square matrix.
Definition ComplexSchur.h:52
ComplexMatrixType m_matT
Definition ComplexSchur.h:248
const ComplexMatrixType & matrixT() const
Returns the triangular matrix in the Schur decomposition.
Definition ComplexSchur.h:162
Index m_maxIters
Definition ComplexSchur.h:253
Index getMaxIterations()
Returns the maximum number of iterations.
Definition ComplexSchur.h:235
NumTraits< Scalar >::Real RealScalar
Definition ComplexSchur.h:65
bool m_isInitialized
Definition ComplexSchur.h:251
ComplexSchur & computeFromHessenberg(const HessMatrixType &matrixH, const OrthMatrixType &matrixQ, bool computeU=true)
Compute Schur decomposition from a given Hessenberg matrix.
ComplexMatrixType m_matU
Definition ComplexSchur.h:248
Eigen::Index Index
Definition ComplexSchur.h:66
const ComplexMatrixType & matrixU() const
Returns the unitary matrix in the Schur decomposition.
Definition ComplexSchur.h:138
bool m_matUisUptodate
Definition ComplexSchur.h:252
ComputationInfo info() const
Reports whether previous computation was successful.
Definition ComplexSchur.h:217
MatrixType::Scalar Scalar
Scalar type for matrices of type _MatrixType.
Definition ComplexSchur.h:64
ComplexSchur(const EigenBase< InputType > &matrix, bool computeU=true)
Constructor; computes Schur decomposition of given matrix.
Definition ComplexSchur.h:113
ComplexSchur & setMaxIterations(Index maxIters)
Sets the maximum number of iterations allowed.
Definition ComplexSchur.h:228
@ MaxRowsAtCompileTime
Definition ComplexSchur.h:59
@ RowsAtCompileTime
Definition ComplexSchur.h:56
@ MaxColsAtCompileTime
Definition ComplexSchur.h:60
@ ColsAtCompileTime
Definition ComplexSchur.h:57
@ Options
Definition ComplexSchur.h:58
static const int m_maxIterationsPerRow
Maximum number of iterations per row.
Definition ComplexSchur.h:245
ComplexSchur(Index size=RowsAtCompileTime==Dynamic ? 1 :RowsAtCompileTime)
Default constructor.
Definition ComplexSchur.h:94
ComputationInfo m_info
Definition ComplexSchur.h:250
std::complex< RealScalar > ComplexScalar
Complex scalar type for _MatrixType.
Definition ComplexSchur.h:74
ComplexSchur & compute(const EigenBase< InputType > &matrix, bool computeU=true)
Computes Schur decomposition of given matrix.
Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > ComplexMatrixType
Type for the matrices in the Schur decomposition.
Definition ComplexSchur.h:81
HessenbergDecomposition< MatrixType > m_hess
Definition ComplexSchur.h:249
_MatrixType MatrixType
Definition ComplexSchur.h:54
Reduces a square matrix to Hessenberg form by an orthogonal similarity transformation.
Definition HessenbergDecomposition.h:58
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 EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition PlainObjectBase.h:143
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition common.h:110
@ IsComplex
Definition common.h:98
#define abs(x)
Definition datatypes.h:17
ComputationInfo
Definition Constants.h:440
@ Success
Definition Constants.h:442
@ NoConvergence
Definition Constants.h:446
int EIGEN_BLAS_FUNC() rot(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pc, RealScalar *ps)
Definition level1_real_impl.h:79
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 sqrt(const bfloat16 &a)
Definition BFloat16.h:511
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Dynamic
Definition Constants.h:22
Definition BandTriangularSolver.h:13
Definition EigenBase.h:30
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:233
static void run(ComplexSchur< MatrixType > &_this, const MatrixType &matrix, bool computeU)
Definition ComplexSchur.h:370
Definition ComplexSchur.h:357
static void run(ComplexSchur< MatrixType > &_this, const MatrixType &matrix, bool computeU)
Definition ComplexSchur.h:359
Definition ForwardDeclarations.h:17