Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Public Types | Public Member Functions
Eigen::RealQZ< _MatrixType > Class Template Reference

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

#include <RealQZ.h>

Public Types

enum  {
  RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, Options = MatrixType::Options, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
  MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
}
 
typedef _MatrixType MatrixType
 
typedef MatrixType::Scalar Scalar
 
typedef std::complex< typename NumTraits< Scalar >::Real > ComplexScalar
 
typedef MatrixType::Index Index
 
typedef Matrix< ComplexScalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > EigenvalueType
 
typedef Matrix< Scalar, ColsAtCompileTime, 1, Options &~RowMajor, MaxColsAtCompileTime, 1 > ColumnVectorType
 

Public Member Functions

 RealQZ (Index size=RowsAtCompileTime==Dynamic?1:RowsAtCompileTime)
 Default constructor. More...
 
 RealQZ (const MatrixType &A, const MatrixType &B, bool computeQZ=true)
 Constructor; computes real QZ decomposition of given matrices. More...
 
const MatrixType & matrixQ () const
 Returns matrix Q in the QZ decomposition. More...
 
const MatrixType & matrixZ () const
 Returns matrix Z 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...
 
RealQZcompute (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.
 
RealQZsetMaxIterations (Index maxIters)
 

Detailed Description

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

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

Template Parameters
_MatrixTypethe 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:

Output:

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

Definition at line 57 of file RealQZ.h.

Constructor & Destructor Documentation

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

Default constructor.

Parameters
[in]sizePositive 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.

Definition at line 86 of file RealQZ.h.

86  : RowsAtCompileTime) :
87  m_S(size, size),
88  m_T(size, size),
89  m_Q(size, size),
90  m_Z(size, size),
91  m_workspace(size*2),
92  m_maxIters(400),
93  m_isInitialized(false)
94  { }
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]AMatrix A.
[in]BMatrix B.
[in]computeQZIf false, A and Z are not computed.

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

Definition at line 104 of file RealQZ.h.

104  :
105  m_S(A.rows(),A.cols()),
106  m_T(A.rows(),A.cols()),
107  m_Q(A.rows(),A.cols()),
108  m_Z(A.rows(),A.cols()),
109  m_workspace(A.rows()*2),
110  m_maxIters(400),
111  m_isInitialized(false) {
112  compute(A, B, computeQZ);
113  }
RealQZ & compute(const MatrixType &A, const MatrixType &B, bool computeQZ=true)
Computes QZ decomposition of given matrix.
Definition: RealQZ.h:557

Member Function Documentation

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]AMatrix A.
[in]BMatrix B.
[in]computeQZIf false, A and Z are not computed.
Returns
Reference to *this

Definition at line 557 of file RealQZ.h.

558  {
559 
560  const Index dim = A_in.cols();
561 
562  eigen_assert (A_in.rows()==dim && A_in.cols()==dim
563  && B_in.rows()==dim && B_in.cols()==dim
564  && "Need square matrices of the same dimension");
565 
566  m_isInitialized = true;
567  m_computeQZ = computeQZ;
568  m_S = A_in; m_T = B_in;
569  m_workspace.resize(dim*2);
570  m_global_iter = 0;
571 
572  // entrance point: hessenberg triangular decomposition
573  hessenbergTriangular();
574  // compute L1 vector norms of T, S into m_normOfS, m_normOfT
575  computeNorms();
576 
577  Index l = dim-1,
578  f,
579  local_iter = 0;
580 
581  while (l>0 && local_iter<m_maxIters)
582  {
583  f = findSmallSubdiagEntry(l);
584  // now rows and columns f..l (including) decouple from the rest of the problem
585  if (f>0) m_S.coeffRef(f,f-1) = Scalar(0.0);
586  if (f == l) // One root found
587  {
588  l--;
589  local_iter = 0;
590  }
591  else if (f == l-1) // Two roots found
592  {
593  splitOffTwoRows(f);
594  l -= 2;
595  local_iter = 0;
596  }
597  else // No convergence yet
598  {
599  // if there's zero on diagonal of T, we can isolate an eigenvalue with Givens rotations
600  Index z = findSmallDiagEntry(f,l);
601  if (z>=f)
602  {
603  // zero found
604  pushDownZero(z,f,l);
605  }
606  else
607  {
608  // We are sure now that S.block(f,f, l-f+1,l-f+1) is underuced upper-Hessenberg
609  // and T.block(f,f, l-f+1,l-f+1) is invertible uper-triangular, which allows to
610  // apply a QR-like iteration to rows and columns f..l.
611  step(f,l, local_iter);
612  local_iter++;
613  m_global_iter++;
614  }
615  }
616  }
617  // check if we converged before reaching iterations limit
618  m_info = (local_iter<m_maxIters) ? Success : NoConvergence;
619  return *this;
620  } // end compute
EIGEN_STRONG_INLINE void resize(Index nbRows, Index nbCols)
template<typename _MatrixType>
ComputationInfo Eigen::RealQZ< _MatrixType >::info ( ) const
inline

Reports whether previous computation was successful.

Returns
Success if computation was succesful, NoConvergence otherwise.

Definition at line 166 of file RealQZ.h.

167  {
168  eigen_assert(m_isInitialized && "RealQZ is not initialized.");
169  return m_info;
170  }
template<typename _MatrixType>
const MatrixType& Eigen::RealQZ< _MatrixType >::matrixQ ( void  ) const
inline

Returns matrix Q in the QZ decomposition.

Returns
A const reference to the matrix Q.

Definition at line 119 of file RealQZ.h.

119  {
120  eigen_assert(m_isInitialized && "RealQZ is not initialized.");
121  eigen_assert(m_computeQZ && "The matrices Q and Z have not been computed during the QZ decomposition.");
122  return m_Q;
123  }
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.

Definition at line 139 of file RealQZ.h.

139  {
140  eigen_assert(m_isInitialized && "RealQZ is not initialized.");
141  return m_S;
142  }
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.

Definition at line 148 of file RealQZ.h.

148  {
149  eigen_assert(m_isInitialized && "RealQZ is not initialized.");
150  return m_T;
151  }
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.

Definition at line 129 of file RealQZ.h.

129  {
130  eigen_assert(m_isInitialized && "RealQZ is not initialized.");
131  eigen_assert(m_computeQZ && "The matrices Q and Z have not been computed during the QZ decomposition.");
132  return m_Z;
133  }
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.

Definition at line 183 of file RealQZ.h.

184  {
185  m_maxIters = maxIters;
186  return *this;
187  }

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