W3cubDocs

/Eigen3

Eigen::RealQZ

template<typename _MatrixType>
class Eigen::RealQZ< _MatrixType >

Performs a real QZ decomposition of a pair of square matrices.

This is defined in the Eigenvalues module.

#include <Eigen/Eigenvalues> 
Template Parameters
_MatrixType the type of the matrix of which we are computing the real QZ decomposition; this is expected to be an instantiation of the Matrix class template.

Given a real square matrices A and B, this class computes the real QZ decomposition: \( A = Q S Z \), \( B = Q T Z \) where Q and Z are real orthogonal matrixes, T is upper-triangular matrix, and S is upper quasi-triangular matrix. An orthogonal matrix is a matrix whose inverse is equal to its transpose, \( U^{-1} = U^T \). A quasi-triangular matrix is a block-triangular matrix whose diagonal consists of 1-by-1 blocks and 2-by-2 blocks where further reduction is impossible due to complex eigenvalues.

The eigenvalues of the pencil \( A - z B \) can be obtained from 1x1 and 2x2 blocks on the diagonals of S and T.

Call the function compute() to compute the real QZ decomposition of a given pair of matrices. Alternatively, you can use the RealQZ(const MatrixType& B, const MatrixType& B, bool computeQZ) constructor which computes the real QZ decomposition at construction time. Once the decomposition is computed, you can use the matrixS(), matrixT(), matrixQ() and matrixZ() functions to retrieve the matrices S, T, Q and Z in the decomposition. If computeQZ==false, some time is saved by not computing matrices Q and Z.

Example:

MatrixXf A = MatrixXf::Random(4,4);
MatrixXf B = MatrixXf::Random(4,4);
RealQZ<MatrixXf> qz(4); // preallocate space for 4x4 matrices
qz.compute(A,B);  // A = Q S Z,  B = Q T Z
 
// print original matrices and result of decomposition
cout << "A:\n" << A << "\n" << "B:\n" << B << "\n";
cout << "S:\n" << qz.matrixS() << "\n" << "T:\n" << qz.matrixT() << "\n";
cout << "Q:\n" << qz.matrixQ() << "\n" << "Z:\n" << qz.matrixZ() << "\n";
 
// verify precision
cout << "\nErrors:"
  << "\n|A-QSZ|: " << (A-qz.matrixQ()*qz.matrixS()*qz.matrixZ()).norm()
  << ", |B-QTZ|: " << (B-qz.matrixQ()*qz.matrixT()*qz.matrixZ()).norm()
  << "\n|QQ* - I|: " << (qz.matrixQ()*qz.matrixQ().adjoint() - MatrixXf::Identity(4,4)).norm()
  << ", |ZZ* - I|: " << (qz.matrixZ()*qz.matrixZ().adjoint() - MatrixXf::Identity(4,4)).norm()
  << "\n";

Output:

A:
   0.68   0.823  -0.444   -0.27
 -0.211  -0.605   0.108  0.0268
  0.566   -0.33 -0.0452   0.904
  0.597   0.536   0.258   0.832
B:
 0.271 -0.967 -0.687  0.998
 0.435 -0.514 -0.198 -0.563
-0.717 -0.726  -0.74 0.0259
 0.214  0.608 -0.782  0.678
S:
-0.668   1.26 -0.598 0.0941
 0.317  -0.27 -0.279   0.64
     0      0 -0.398 -0.164
     0      0      0  -1.12
T:
 -1.55      0  0.342  -0.54
     0   1.01 -0.457  0.128
     0      0  -1.25  0.438
     0      0      0  0.746
Q:
-0.587 -0.138  0.552  0.576
  0.19 -0.208  0.761 -0.585
-0.292  0.918  0.152 -0.223
-0.731  -0.31 -0.306 -0.526
Z:
-0.0204   0.213   -0.78   0.588
 -0.961  -0.184   -0.14  -0.153
 -0.269   0.783   0.462    0.32
-0.0674  -0.555   0.398   0.727
 
Errors:
|A-QSZ|: 1.36e-06, |B-QTZ|: 1.83e-06
|QQ* - I|: 8.18e-07, |ZZ* - I|: 7.36e-07
Note
The implementation is based on the algorithm in "Matrix Computations" by Gene H. Golub and Charles F. Van Loan, and a paper "An algorithm for generalized eigenvalue problems" by C.B.Moler and G.W.Stewart.
See also
class RealSchur, class ComplexSchur, class EigenSolver, class ComplexEigenSolver
typedef Eigen::Index Index
RealQZ & compute (const MatrixType &A, const MatrixType &B, bool computeQZ=true)
Computes QZ decomposition of given matrix. More...
ComputationInfo info () const
Reports whether previous computation was successful. More...
Index iterations () const
Returns number of performed QR-like iterations.
const MatrixType & matrixQ () const
Returns matrix Q in the QZ decomposition. More...
const MatrixType & matrixS () const
Returns matrix S in the QZ decomposition. More...
const MatrixType & matrixT () const
Returns matrix S in the QZ decomposition. More...
const MatrixType & matrixZ () const
Returns matrix Z in the QZ decomposition. More...
RealQZ (const MatrixType &A, const MatrixType &B, bool computeQZ=true)
Constructor; computes real QZ decomposition of given matrices. More...
RealQZ (Index size=RowsAtCompileTime==Dynamic ? 1 :RowsAtCompileTime)
Default constructor. More...
RealQZ & setMaxIterations (Index maxIters)

Index

template<typename _MatrixType >
typedef Eigen::Index Eigen::RealQZ< _MatrixType >::Index
Deprecated:
since Eigen 3.3

RealQZ() [1/2]

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

Default constructor.

Parameters
[in] size Positive integer, size of the matrix whose QZ 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.

RealQZ() [2/2]

template<typename _MatrixType >
Eigen::RealQZ< _MatrixType >::RealQZ ( const MatrixType & A,
const MatrixType & B,
bool computeQZ = true
)
inline

Constructor; computes real QZ decomposition of given matrices.

Parameters
[in] A Matrix A.
[in] B Matrix B.
[in] computeQZ If false, A and Z are not computed.

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

compute()

template<typename MatrixType >
RealQZ< MatrixType > & Eigen::RealQZ< MatrixType >::compute ( const MatrixType & A,
const MatrixType & B,
bool computeQZ = true
)

Computes QZ decomposition of given matrix.

Parameters
[in] A Matrix A.
[in] B Matrix B.
[in] computeQZ If false, A and Z are not computed.
Returns
Reference to *this

info()

template<typename _MatrixType >
ComputationInfo Eigen::RealQZ< _MatrixType >::info ( ) const
inline

Reports whether previous computation was successful.

Returns
Success if computation was successful, NoConvergence otherwise.

matrixQ()

template<typename _MatrixType >
const MatrixType& Eigen::RealQZ< _MatrixType >::matrixQ ( ) const
inline

Returns matrix Q in the QZ decomposition.

Returns
A const reference to the matrix Q.

matrixS()

template<typename _MatrixType >
const MatrixType& Eigen::RealQZ< _MatrixType >::matrixS ( ) const
inline

Returns matrix S in the QZ decomposition.

Returns
A const reference to the matrix S.

matrixT()

template<typename _MatrixType >
const MatrixType& Eigen::RealQZ< _MatrixType >::matrixT ( ) const
inline

Returns matrix S in the QZ decomposition.

Returns
A const reference to the matrix S.

matrixZ()

template<typename _MatrixType >
const MatrixType& Eigen::RealQZ< _MatrixType >::matrixZ ( ) const
inline

Returns matrix Z in the QZ decomposition.

Returns
A const reference to the matrix Z.

setMaxIterations()

template<typename _MatrixType >
RealQZ& Eigen::RealQZ< _MatrixType >::setMaxIterations ( Index maxIters )
inline

Sets the maximal number of iterations allowed to converge to one eigenvalue or decouple the problem.


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

© Eigen.
Licensed under the MPL2 License.
https://eigen.tuxfamily.org/dox/classEigen_1_1RealQZ.html