SourcePro® API Reference Guide

 
List of all members | Public Member Functions
RWCODecomp< TypeT, QRCalc > Class Template Reference

Encapsulates a complete orthogonal decomposition. More...

#include <rw/lapack/co.h>

Inheritance diagram for RWCODecomp< TypeT, QRCalc >:
RWLeastSqQR< TypeT, QRCalc >

Public Member Functions

 RWCODecomp ()
 
 RWCODecomp (const RWCODecomp< TypeT, QRCalc > &A)
 
 RWCODecomp (const RWQRDecomp< TypeT, QRCalc > &A, double tol=0)
 
 RWCODecomp (const RWGenMat< TypeT > &A, double tol=0)
 
unsigned cols () const
 
void factor (const RWQRDecomp< TypeT, QRCalc > &A, double tol=0)
 
void factor (const RWGenMat< TypeT > &A, double tol=0)
 
RWGenMat< TypeT > P () const
 
RWMathVec< TypeT > PTx (const RWMathVec< TypeT > &x) const
 
RWMathVec< TypeT > Px (const RWMathVec< TypeT > &x) const
 
RWGenMat< TypeT > Q () const
 
RWMathVec< TypeT > QTx (const RWMathVec< TypeT > &x) const
 
RWMathVec< TypeT > Qx (const RWMathVec< TypeT > &x) const
 
unsigned rank () const
 
unsigned rows () const
 
RWUpperTriMat< TypeT > T () const
 
RWMathVec< TypeT > Tinvx (const RWMathVec< TypeT > &x) const
 
RWMathVec< TypeT > TTinvx (const RWMathVec< TypeT > &x) const
 
RWMathVec< TypeT > TTx (const RWMathVec< TypeT > &x) const
 
RWMathVec< TypeT > Tx (const RWMathVec< TypeT > &x) const
 
RWGenMat< TypeT > Z () const
 
RWMathVec< TypeT > ZTx (const RWMathVec< TypeT > &x) const
 
RWMathVec< TypeT > Zx (const RWMathVec< TypeT > &x) const
 

Detailed Description

template<class TypeT, class QRCalc>
class RWCODecomp< TypeT, QRCalc >

The class RWCODecomp encapsulates a complete orthogonal decomposition. A complete orthogonal decomposition decomposes a general rectangular matrix A into the form:

\[ AP = Q \begin{bmatrix} T & 0\\ 0 & 0 \end{bmatrix} Z^{\prime} \]

where P is a permutation, Q and Z are orthogonal matrices, and T is an upper triangular matrix. This transformation is closely related to the QR transformation. The difference is that an extra orthogonal transformation, Z, is applied to zero out the columns to the right of T.

Note
For greater flexibility, the user can implement this method, or the Linear Algebra Module provides two classes to perform this function — RWQRCalc and RWQRCalcP3. Please see their descriptions in this reference guide for more information.
Synopsis
#include <rw/lapack/qrcalc3.h>
#include <rw/lapack/co.h>
RWCODecomp<double, RWQRCalcP3<double> > QTZ(A); // A is an RWGenMat<double>
Example

This decomposition is commonly used in the solution of least squares problems. The implementation of the Linear Algebra Module class RWLeastSqQR uses the complete orthogonal transformation.

#include <rw/lapack/qrcalc3.h>
#include <iostream>
#include <rw/lapack/co.h>
int main()
{
std::cin >> A;
std::cout << "Input matrix: " << A << endl;
std::cout << "Permutation: " << co.P() <<
std::endl;
std::cout << "Q: " << co.Q() << endl;
std::cout << "Z: " << co.Z() << endl;
std::cout << "T: " << co.T() << endl;
return 0;
}

Constructor & Destructor Documentation

template<class TypeT, class QRCalc>
RWCODecomp< TypeT, QRCalc >::RWCODecomp ( )

Default constructor. Builds a decomposition of size 0 x 0.

template<class TypeT, class QRCalc>
RWCODecomp< TypeT, QRCalc >::RWCODecomp ( const RWCODecomp< TypeT, QRCalc > &  A)

Copy constructor. References the data in the original decomposition for efficiency.

template<class TypeT, class QRCalc>
RWCODecomp< TypeT, QRCalc >::RWCODecomp ( const RWQRDecomp< TypeT, QRCalc > &  A,
double  tol = 0 
)

Builds a complete orthogonal representation of the matrix represented by the QR decomposition. Entries along the diagonal of the R factor of the QR decomposition that are smaller in magnitude than tol are treated as 0.

template<class TypeT, class QRCalc>
RWCODecomp< TypeT, QRCalc >::RWCODecomp ( const RWGenMat< TypeT > &  A,
double  tol = 0 
)

Builds a complete orthogonal decomposition of A. Entries along the diagonal of T that would be smaller in magnitude than tol are treated as 0.

Member Function Documentation

template<class TypeT, class QRCalc>
unsigned RWCODecomp< TypeT, QRCalc >::cols ( ) const
inline

Returns the number of columns in the matrix that the decomposition represents.

template<class TypeT, class QRCalc>
void RWCODecomp< TypeT, QRCalc >::factor ( const RWQRDecomp< TypeT, QRCalc > &  A,
double  tol = 0 
)

Builds a complete orthogonal representation of the matrix represented by the QR decomposition. Entries along the diagonal of the R factor of the QR decomposition that are smaller in magnitude than tol are treated as 0. The current contents of the decomposition are lost.

template<class TypeT, class QRCalc>
void RWCODecomp< TypeT, QRCalc >::factor ( const RWGenMat< TypeT > &  A,
double  tol = 0 
)

Builds a complete orthogonal decomposition of A. Entries along the diagonal of T that would be smaller in magnitude than tol are treated as 0. The current contents of the decomposition are lost.

template<class TypeT, class QRCalc>
RWGenMat<TypeT> RWCODecomp< TypeT, QRCalc >::P ( ) const
inline

Computes an explicit representation of the permutation matrix.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWCODecomp< TypeT, QRCalc >::PTx ( const RWMathVec< TypeT > &  x) const
inline

Computes the inner product of the permutation, or its transpose, and the vector x.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWCODecomp< TypeT, QRCalc >::Px ( const RWMathVec< TypeT > &  x) const
inline

Computes the inner product of the permutation, or its transpose, and the vector x.

template<class TypeT, class QRCalc>
RWGenMat<TypeT> RWCODecomp< TypeT, QRCalc >::Q ( ) const
inline

Computes an explicit representation of the orthogonal matrix Q.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWCODecomp< TypeT, QRCalc >::QTx ( const RWMathVec< TypeT > &  x) const
inline

Computes the inner product of the orthogonal matrix Q, or its (conjugate) transpose, and the vector x.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWCODecomp< TypeT, QRCalc >::Qx ( const RWMathVec< TypeT > &  x) const
inline

Computes the inner product of the orthogonal matrix Q, or its (conjugate) transpose, and the vector x.

template<class TypeT, class QRCalc>
unsigned RWCODecomp< TypeT, QRCalc >::rank ( ) const
inline

Returns the rank of the matrix that the decomposition represents. The rank is also the number of rows and columns in the factor T.

template<class TypeT, class QRCalc>
unsigned RWCODecomp< TypeT, QRCalc >::rows ( ) const
inline

Returns the number of rows in the matrix that the decomposition represents.

template<class TypeT, class QRCalc>
RWUpperTriMat<TypeT> RWCODecomp< TypeT, QRCalc >::T ( ) const

Returns an explicit representation of the triangular matrix T.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWCODecomp< TypeT, QRCalc >::Tinvx ( const RWMathVec< TypeT > &  x) const

Computes the inner product of the matrix T, its (conjugate) transpose, its inverse, or its (conjugate) transpose inverse, and the vector x.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWCODecomp< TypeT, QRCalc >::TTinvx ( const RWMathVec< TypeT > &  x) const

Computes the inner product of the matrix T, its (conjugate) transpose, its inverse, or its (conjugate) transpose inverse, and the vector x.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWCODecomp< TypeT, QRCalc >::TTx ( const RWMathVec< TypeT > &  x) const

Computes the inner product of the matrix T, its (conjugate) transpose, its inverse, or its (conjugate) transpose inverse, and the vector x.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWCODecomp< TypeT, QRCalc >::Tx ( const RWMathVec< TypeT > &  x) const

Computes the inner product of the matrix T, its (conjugate) transpose, its inverse, or its (conjugate) transpose inverse, and the vector x.

template<class TypeT, class QRCalc>
RWGenMat<TypeT> RWCODecomp< TypeT, QRCalc >::Z ( ) const

Computes an explicit representation of the orthogonal matrix Z.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWCODecomp< TypeT, QRCalc >::ZTx ( const RWMathVec< TypeT > &  x) const

Computes the inner product of the orthogonal matrix Z, or its (conjugate) transpose, and the vector x.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWCODecomp< TypeT, QRCalc >::Zx ( const RWMathVec< TypeT > &  x) const

Computes the inner product of the orthogonal matrix Z, or its (conjugate) transpose, and the vector x.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.