>
>#include <rw/dqr.h> // DoubleQRDecomp #include <rw/fqr.h> // FloatQRDecomp #include <rw/cqr.h> // DComplexQRDecomp DoubleQRDecomp qr(A); // A is a RWGenMat<double>
A QR decomposition is a representation of a matrix A of the form:
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 classes {TYPE}QRDecomp are 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 complete orthogonal decomposition classes, {TYPE}QRDecomp. A common use of QR decompositions is to solve linear least squares problems; this is most conveniently done using the {TYPE}LeastSqQR 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 classes, {TYPE}QRDecompServer, to do the construction.
>#include <rw/iostream.h> #include <rw/dqr.h> main() { RWGenMat<double> A; cin >> A; DoubleQRDecomp qr(A); cout << "Input matrix: " << A << endl; cout << "Permutation: " << qr.P() << endl; cout << "Q: " << qr.Q() << endl; cout << "R: " << qr.R() << endl; }>
DoubleQRDecomp(); FloatQRDecomp(); DComplexQRDecomp();
Default constructor. Builds a decomposition of size 0 x 0.
DoubleQRDecomp(const DoubleQRDecomp& A); FloatQRDecomp(const FloatQRDecomp& A); DComplexQRDecomp(const DComplexQRDecomp& A);
Copy constructor. References the data in the original decomposition for efficiency.
DoubleQRDecomp(const RWGenMat<double>& A); FloatQRDecomp(const RWGenMat<float>& A); DComplexQRDecomp(const RWGenMat<DComplex>& 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 {TYPE}QRDecompServer.
unsigned FloatQRDecomp::cols(); unsigned DoubleQRDecomp::cols(); unsigned DComplexQRDecomp::cols();
Returns the number of columns in the matrix that the decomposition represents.
void DoubleQRDecomp::factor(const RWGenMat<double>& A); void FloatQRDecomp::factor(const RWGenMat<float>& A); void DComplexQRDecomp::factor(const RWGenMat<DComplex>& A);
Builds a QR decomposition of A.
RWGenMat<float> FloatQRDecomp::P(); RWGenMat<double> DoubleQRDecomp::P(); RWGenMat<DComplex> DComplexQRDecomp::P();
Computes an explicit representation of the permutation matrix.
RWMathVec<float> FloatQRDecomp::Px(const RWMathVec<float>& x); RWMathVec<float> FloatQRDecomp::PTx(const RWMathVec<float>& x); RWMathVec<double> DoubleQRDecomp::Px(const RWMathVec<double>& x); RWMathVec<double> DoubleQRDecomp::PTx(const RWMathVec<double>& x); RWMathVec<DComplex> DComplexQRDecomp::Px(const RWMathVec<DComplex>& x); RWMathVec<DComplex> DComplexQRDecomp::PTx(const RWMathVec<DComplex>& x);
Computes the inner product of the permutation, or its transpose, and the vector x.
RWGenMat<float> FloatQRDecomp::Q(); RWGenMat<double> DoubleQRDecomp::Q(); RWGenMat<DComplex> DComplexQRDecomp::Q();
Computes an explicit representation of the orthogonal matrix Q.
RWMathVec<float> FloatQRDecomp::Qx(const RWMathVec<float>& x); RWMathVec<float> FloatQRDecomp::QTx(const RWMathVec<float>& x); RWMathVec<double> DoubleQRDecomp::Qx(const RWMathVec<double>& x); RWMathVec<double> DoubleQRDecomp::QTx(const RWMathVec<double>& x); RWMathVec<DComplex> DComplexQRDecomp::Qx(const RWMathVec<DComplex>& x); RWMathVec<DComplex> DComplexQRDecomp::QTx(const RWMathVec<DComplex>& x);
Computes the inner product of the orthogonal matrix Q, or its (conjugate) transpose, and the vector x.
RWGenMat<float> FloatQRDecomp::R(); RWGenMat<double> DoubleQRDecomp::R(); RWGenMat<DComplex> DComplexQRDecomp::R();
Returns an explicit representation of the upper trapezoidal matrix R.
RWMathVec<float> FloatQRDecomp::Rdiagonal(); RWMathVec<double> DoubleQRDecomp::Rdiagonal(); RWMathVec<DComplex> DComplexQRDecomp::Rdiagonal();
Returns the main diagonal of the upper trapezoidal matrix R.
RWMathVec<float> FloatQRDecomp::Rx(const RWMathVec<float>& x); RWMathVec<float> FloatQRDecomp::RTx(const RWMathVec<float>& x); RWMathVec<float> FloatQRDecomp::Rinvx(const RWMathVec<float>& x); RWMathVec<float> FloatQRDecomp::RTinvx(const RWMathVec<float>& x); RWMathVec<double> DoubleQRDecomp::Rx(const RWMathVec<double>& x); RWMathVec<double> DoubleQRDecomp::RTx(const RWMathVec<double>& x); RWMathVec<double> DoubleQRDecomp::Rinvx(const RWMathVec<double>& x); RWMathVec<double> DoubleQRDecomp::RTinvx(const RWMathVec<double>& x); RWMathVec<DComplex> DComplexQRDecomp::Rx(const RWMathVec<DComplex>& x); RWMathVec<DComplex> DComplexQRDecomp::RTx(const RWMathVec<DComplex>& x); RWMathVec<DComplex> DComplexQRDecomp::Rinvx(const RWMathVec<DComplex>& x); RWMathVec<DComplex> DComplexQRDecomp::RTinvx(const RWMathVec<DComplex>& x);
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.
unsigned FloatQRDecomp::rows(); unsigned DoubleQRDecomp::rows(); unsigned DComplexQRDecomp::rows();
Returns the number of rows in the matrix that the decomposition represents.
void FloatQRDecomp::operator=(const FloatQRDecomp&); void DoubleQRDecomp::operator=(const DoubleQRDecomp&); void DComplexQRDecomp::operator=(const DComplexQRDecomp&);
Assigns the passed value to this decomposition . The current contents of the decomposition are lost.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.