rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWQRDecomp< TypeT, QRCalc > Class Template Reference
[Decomposition]

Used to construct and work with QR decompositions. More...

#include <rw/lapack/qr.h>

List of all members.

Public Member Functions

 RWQRDecomp ()
 RWQRDecomp (const RWQRDecomp< TypeT, QRCalc > &)
 RWQRDecomp (const RWGenMat< TypeT > &A)
void factor (const RWGenMat< TypeT > &A)
unsigned rows () const
unsigned cols () const
RWGenMat< TypeT > P () const
RWGenMat< TypeT > R () const
RWMathVec< TypeT > Rdiagonal () const
RWGenMat< TypeT > Q () const
RWMathVec< TypeT > Px (const RWMathVec< TypeT > &x) const
RWMathVec< TypeT > PTx (const RWMathVec< TypeT > &x) const
RWMathVec< TypeT > Rx (const RWMathVec< TypeT > &x) const
RWMathVec< TypeT > RTx (const RWMathVec< TypeT > &x) const
RWMathVec< TypeT > Rinvx (const RWMathVec< TypeT > &x) const
RWMathVec< TypeT > RTinvx (const RWMathVec< TypeT > &x) const
RWMathVec< TypeT > Qx (const RWMathVec< TypeT > &x) const
RWMathVec< TypeT > QTx (const RWMathVec< TypeT > &x) const
void operator= (const RWQRDecomp< TypeT, QRCalc > &)

Detailed Description

template<class TypeT, class QRCalc>
class RWQRDecomp< TypeT, QRCalc >

A QR decomposition is a representation of a matrix A of the form:

\[ AP = QR \]

where P is a permutation matrix, Q is orthogonal, and R is upper trapezoidal, or upper triangular if A is full rank, with no more columns than rows.

The class RWQRDecomp<T,QRCalc> is used to construct and work with QR decompositions. Sometimes it is desirable to zero out the rectangular part of the trapezoidal matrix R; this can be done using the orthogonal decomposition class,RWQRDecomp<T,QRCalc>. A common use of QR decompositions is to solve linear least squares problems; this is most conveniently done using the RWLeastSqQR<T,QRCalc> class.

You may need more control over the computation of the decomposition than is provided by this class. For example, if you don't want to use pivoting, you can use the QR decomposition server class, RWQRDecompServer<T,QRCalc>, to do the construction.

Note:
For greater flexibility, the user can implement this method, or the Linear Algebra Module provides two classes to perform this function - RWQRCalc<T> and RWQRCalcP3<T> . Please see their descriptions in this reference guide for more information.

Synopsis

 #include <rw/lapack/qr.h>
 #include <rw/lapack/qrcalcp3.h>
 
 RWQRDecomp<double, RWQRCalcP3<double> > qr(A);  // A is a RWGenMat<double>

Examples

 #include <rw/iostream>
 #include <rw/math/genmat.h>
 #include <rw/lapack/qr.h>
 #include <rw/lapack/qrcalcp3.h>
 
 int main()
 {
     RWGenMat<double> A;
     std::cin >> A;
     RWQRDecomp<double, RWQRCalc3P<double> > qr(A);
     std::cout << "Input matrix: " << A << std::endl;
     std::cout << "Permutation: " << qr.P() <<
                  std::endl;
     std::cout << "Q: " << qr.Q() << std::endl;
     std::cout << "R: " << qr.R() << std::endl;
     return 0;
 }

Constructor & Destructor Documentation

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

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

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

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

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

Builds a QR decomposition of A. By default, pivoting is done so that the entries along the diagonal of R are non-increasing. To construct a QR decomposition with non-default options, use the QR decomposition server class RWQRDecompServer<T,QRCalc> .


Member Function Documentation

template<class TypeT, class QRCalc>
unsigned RWQRDecomp< TypeT, QRCalc >::cols (  )  const [inline]

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

template<class TypeT, class QRCalc>
void RWQRDecomp< TypeT, QRCalc >::factor ( const RWGenMat< TypeT > &  A  ) 

Builds a QR decomposition of A.

template<class TypeT, class QRCalc>
void RWQRDecomp< TypeT, QRCalc >::operator= ( const RWQRDecomp< TypeT, QRCalc > &   ) 

Assigns the passed value to this decomposition. The current contents of the decomposition are lost.

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

Computes an explicit representation of the permutation matrix.

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

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

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

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

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

Computes an explicit representation of the orthogonal matrix Q.

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

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

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

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

template<class TypeT, class QRCalc>
RWGenMat<TypeT> RWQRDecomp< TypeT, QRCalc >::R (  )  const

Returns an explicit representation of the upper trapezoidal matrix R.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWQRDecomp< TypeT, QRCalc >::Rdiagonal (  )  const

Returns the main diagonal of the upper trapezoidal matrix R.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWQRDecomp< TypeT, QRCalc >::Rinvx ( const RWMathVec< TypeT > &  x  )  const

Computes the inner product of the matrix R, its (conjugate) transpose, its inverse, or its (conjugate) transpose inverse, and the vector x. An exception is raised if you call Rinvx() or RTinvx() for a singular decomposition.

template<class TypeT, class QRCalc>
unsigned RWQRDecomp< TypeT, QRCalc >::rows (  )  const [inline]

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

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWQRDecomp< TypeT, QRCalc >::RTinvx ( const RWMathVec< TypeT > &  x  )  const

Computes the inner product of the matrix R, its (conjugate) transpose, its inverse, or its (conjugate) transpose inverse, and the vector x. An exception is raised if you call Rinvx() or RTinvx() for a singular decomposition.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWQRDecomp< TypeT, QRCalc >::RTx ( const RWMathVec< TypeT > &  x  )  const

Computes the inner product of the matrix R, its (conjugate) transpose, its inverse, or its (conjugate) transpose inverse, and the vector x. An exception is raised if you call Rinvx() or RTinvx() for a singular decomposition.

template<class TypeT, class QRCalc>
RWMathVec<TypeT> RWQRDecomp< TypeT, QRCalc >::Rx ( const RWMathVec< TypeT > &  x  )  const

Computes the inner product of the matrix R, its (conjugate) transpose, its inverse, or its (conjugate) transpose inverse, and the vector x. An exception is raised if you call Rinvx() or RTinvx() for a singular decomposition.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.