SDPSL
Semidefinite Programming Specification Library
|
Provides the QR decomposition of a matrix with entries of type T
.
More...
#include <qrdec.h>
Public Member Functions | |
QRDecomposition (const std::vector< T > &A, int m, int n, double sing_eps=1e-10) | |
Initializes an instance by computing the QR decomposition. More... | |
int | rank () const |
Returns the rank of the matrix, as determined by the QR decomposition. More... | |
int | perm (int j) const |
Returns the original index of the j-th column after the pivoting. More... | |
const T & | scaling_factor () const |
Returns the scaling factor used. More... | |
const T & | R (int i, int j) const |
Returns entry (i, j) of matrix \(R\) of the decomposition. | |
void | Q_mul (std::vector< T > &x) const |
Multiplies a vector x on the left by the matrix \(Q\). | |
void | Q_transpose_mul (std::vector< T > &x) const |
Multiplies a vector x on the left by the matrix \(Q^{\sf T}\). | |
Provides the QR decomposition of a matrix with entries of type T
.
The decomposition is computed using Householder reflectors with column pivoting. The algorithm is column-oriented, and the input matrix should be provided as a vector in column-major order.
Scaling is performed to avoid overflow, the scaling factor should be taken into account when using the decomposition.
|
inline |
Initializes an instance by computing the QR decomposition.
A | is the input matrix as a vector in column-major order. |
m | number of rows in A. |
n | number of columns in A. |
sing_eps | is used during the process to decide the rank of A; during the decomposition, a column whose squared norm is less than sing_eps is considered to be zero. |
ValueError | if there are less rows than columns. |
|
inline |
Returns the original index of the j-th column after the pivoting.
The decomposition is implemented with column pivoting; we have \(AP = QR\), where \(P\) is a permutation matrix that permutes the columns of \(A\). So we have a decomposition for \(AP\), which is a permuted version of \(A\). The permutation is given as follows: the j-th column of \(AP\) is the column of \(A\) with index QR.perm(j)
.
|
inline |
Returns the rank of the matrix, as determined by the QR decomposition.
If the rank is \(r\), then
\[ R = \begin{pmatrix} R_{11}&R_{12}\\ 0&0 \end{pmatrix} \]
where \(R_{11}\) is an \(r \times r\) matrix.
|
inline |
Returns the scaling factor used.
The decomposition is not computed for the given matrix \(A\), but for \(s^{-1} A\), where \(s\) is the scaling factor used.