QRMatrix computes QR decomposition of a given scalar/complex matrix A into the following:
More...
#include <QRMatrix.H>
Public Types | |
| enum | modes : uint8_t { FULL = 1 , ECONOMY = 2 } |
| Options for the decomposition mode. More... | |
| enum | outputs : uint8_t { ONLY_Q = 1 , ONLY_R = 2 , BOTH_QR = 3 } |
| Options for the output types. More... | |
| enum | pivoting : bool { FALSE = false , TRUE = true } |
| Options for the column pivoting. More... | |
| typedef MatrixType::cmptType | cmptType |
| typedef MatrixType::size_type | size_type |
| typedef MatrixType::value_type | value_type |
| typedef SquareMatrix< cmptType > | SMatrix |
| typedef RectangularMatrix< cmptType > | RMatrix |
Public Member Functions | |
| QRMatrix ()=delete | |
| No default construct. | |
| QRMatrix (const QRMatrix &)=delete | |
| No copy construct. | |
| QRMatrix & | operator= (const QRMatrix &)=delete |
| No copy assignment. | |
| QRMatrix (const modes mode, const outputs output, const bool pivoting, MatrixType &A) | |
| Construct with a matrix and perform QR decomposition. | |
| QRMatrix (const MatrixType &A, const modes mode, const outputs output=outputs::BOTH_QR, const bool pivoting=false) | |
| Construct with a const matrix and perform QR decomposition. | |
| const MatrixType & | Q () const noexcept |
| Return const reference to Q. | |
| MatrixType & | Q () noexcept |
| Return reference to Q. | |
| const MatrixType & | R () const noexcept |
| Return const reference to R. | |
| MatrixType & | R () noexcept |
| Return reference to R. | |
| const labelList & | p () const noexcept |
| Return const reference to p. | |
| SMatrix | P () const |
| Create and return the permutation matrix. | |
| void | solve (List< cmptType > &x, const UList< cmptType > &source) const |
| Solve the linear system with the given source and return the solution in the argument x. | |
| template<class Addr> | |
| void | solve (List< cmptType > &x, const IndirectListBase< cmptType, Addr > &source) const |
| Solve the linear system with the given source and return the solution in the argument x. | |
| tmp< Field< cmptType > > | solve (const UList< cmptType > &source) const |
| Solve the linear system with the given source and return the solution. | |
| template<class Addr> | |
| tmp< Field< cmptType > > | solve (const IndirectListBase< cmptType, Addr > &source) const |
| Solve the linear system with the given source and return the solution. | |
| RMatrix | solve (const RMatrix &b) |
| Solve a row-echelon-form linear system (Ax = b) starting from the bottom by back substitution. | |
| SMatrix | inv () const |
| Return the inverse of (Q*R), solving x = (Q*R).inv()*source. | |
| template<class Addr> | |
| Foam::tmp< Foam::Field< typename MatrixType::cmptType > > | solve (const IndirectListBase< cmptType, Addr > &source) const |
QRMatrix computes QR decomposition of a given scalar/complex matrix A into the following:
A = Q R
or in case of QR decomposition with column pivoting:
A P = Q R
where
![]() | = | Unitary/orthogonal matrix |
![]() | = | Upper triangular matrix |
![]() | = | Permutation matrix |
References:
TNT implementation:
Pozo, R. (1997).
Template Numerical Toolkit for linear algebra:
High performance programming with C++
and the Standard Template Library.
The International Journal of Supercomputer Applications
and High Performance Computing, 11(3), 251-263.
DOI:10.1177/109434209701100307
QR decomposition with column pivoting (tag:QSB):
Quintana-Ortí, G., Sun, X., & Bischof, C. H. (1998).
A BLAS-3 version of the QR factorization with column pivoting.
SIAM Journal on Scientific Computing, 19(5), 1486-1494.
DOI:10.1137/S1064827595296732
Moore-Penrose inverse algorithm (tags:KP; KPP):
Katsikis, V. N., & Pappas, D. (2008).
Fast computing of the Moore-Penrose inverse matrix.
Electronic Journal of Linear Algebra, 17(1), 637-650.
DOI:10.13001/1081-3810.1287
Katsikis, V. N., Pappas, D., & Petralias, A. (2011).
An improved method for the computation of
the Moore–Penrose inverse matrix.
Applied Mathematics and Computation, 217(23), 9828-9834.
DOI:10.1016/j.amc.2011.04.080
Tolerance for the Moore-Penrose inverse algorithm (tag:TA):
Toutounian, F., & Ataei, A. (2009).
A new method for computing Moore–Penrose inverse matrices.
Journal of Computational and applied Mathematics, 228(1), 412-417.
DOI:10.1016/j.cam.2008.10.008
Input:
![]() | = | RectangularMatrix<Type> or SquareMatrix<Type> |
Options for the decomposition mode:
![]() | = | compute full-size decomposition |
![]() | = | compute economy-size decomposition |
Options for the output types:
![]() | = | compute only Q |
![]() | = | compute only R |
![]() | = | compute both Q and R |
Options for the column pivoting:
![]() | = | switch off column pivoting |
![]() | = | switch on column pivoting |
Output:
![]() | = | m-by-m (FULL) or m-by-k (ECONOMY) with k = min(m,n) |
![]() | = | m-by-n (FULL) or k-by-n (ECONOMY) with k = min(m,n) |
![]() | = | n-element label list |
![]() | = | n-by-n permutation matrix |
Notes
QRMatrix involves modified implementations of the public-domain library TNT, which is available at https://math.nist.gov/tnt/index.html.Q and R are always of the same type of the matrix A.Type can be scalar or complex.Definition at line 207 of file QRMatrix.H.
| typedef MatrixType::cmptType cmptType |
Definition at line 211 of file QRMatrix.H.
| typedef MatrixType::size_type size_type |
Definition at line 212 of file QRMatrix.H.
| typedef MatrixType::value_type value_type |
Definition at line 213 of file QRMatrix.H.
| typedef SquareMatrix<cmptType> SMatrix |
Definition at line 215 of file QRMatrix.H.
| typedef RectangularMatrix<cmptType> RMatrix |
Definition at line 216 of file QRMatrix.H.
| enum modes : uint8_t |
Options for the decomposition mode.
| Enumerator | |
|---|---|
| FULL | compute full-size decomposition |
| ECONOMY | compute economy-size decomposition |
Definition at line 221 of file QRMatrix.H.
| enum outputs : uint8_t |
Options for the output types.
| Enumerator | |
|---|---|
| ONLY_Q | compute only Q |
| ONLY_R | compute only R |
| BOTH_QR | compute both Q and R |
Definition at line 230 of file QRMatrix.H.
| enum pivoting : bool |
Options for the column pivoting.
| Enumerator | |
|---|---|
| FALSE | switch off column pivoting |
| TRUE | switch on column pivoting |
Definition at line 240 of file QRMatrix.H.
|
delete |
No default construct.
Referenced by operator=(), and QRMatrix().

|
delete |
|
explicit |
Construct with a matrix and perform QR decomposition.
Definition at line 375 of file QRMatrix.C.
References A, and Foam::mode().

|
explicit |
Construct with a const matrix and perform QR decomposition.
Definition at line 408 of file QRMatrix.C.
References A, and Foam::mode().

No copy assignment.
References A, BOTH_QR, Foam::mode(), and QRMatrix().

|
inlinenoexcept |
Return const reference to Q.
Definition at line 386 of file QRMatrix.H.
References Foam::noexcept.
Referenced by Foam::MatrixTools::pinv().

|
inlinenoexcept |
|
inlinenoexcept |
Return const reference to R.
Definition at line 402 of file QRMatrix.H.
References Foam::noexcept.
Referenced by Foam::MatrixTools::pinv().

|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
Create and return the permutation matrix.
Definition at line 26 of file QRMatrixI.H.
Referenced by P(), and Foam::MatrixTools::pinv().


| void solve | ( | List< cmptType > & | x, |
| const UList< cmptType > & | source ) const |
Solve the linear system with the given source and return the solution in the argument x.
Definition at line 441 of file QRMatrix.C.
References x.
Referenced by Foam::MatrixTools::pinv().

| void solve | ( | List< cmptType > & | x, |
| const IndirectListBase< cmptType, Addr > & | source ) const |
Solve the linear system with the given source and return the solution in the argument x.
Definition at line 453 of file QRMatrix.C.
References x.
| Foam::tmp< Foam::Field< typename MatrixType::cmptType > > solve | ( | const UList< cmptType > & | source | ) | const |
Solve the linear system with the given source and return the solution.
Definition at line 465 of file QRMatrix.C.
| tmp< Field< cmptType > > solve | ( | const IndirectListBase< cmptType, Addr > & | source | ) | const |
Solve the linear system with the given source and return the solution.
References b.
| Foam::RectangularMatrix< typename MatrixType::cmptType > solve | ( | const RMatrix & | b | ) |
Solve a row-echelon-form linear system (Ax = b) starting from the bottom by back substitution.
A = R: Non-singular upper-triangular square matrix (m-by-m) b: Source (m-by-p) x: Solution (m-by-p)
Definition at line 496 of file QRMatrix.C.
References Foam::abort(), alpha, b, Foam::diag(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, k, Matrix< Form, Type >::m(), Foam::mag(), Foam::rhs(), Foam::tab, WarningInFunction, and Foam::Zero.

| Foam::QRMatrix< MatrixType >::SMatrix inv | ( | ) | const |
Return the inverse of (Q*R), solving x = (Q*R).inv()*source.
Definition at line 552 of file QRMatrix.C.
References Foam::inv(), inv(), Matrix< Form, Type >::m(), and x.
Referenced by inv().


| Foam::tmp< Foam::Field< typename MatrixType::cmptType > > solve | ( | const IndirectListBase< cmptType, Addr > & | source | ) | const |
Definition at line 481 of file QRMatrix.C.