SDPSL
Semidefinite Programming Specification Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Pages
sdp::QRDecomposition< T > Class Template Reference

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}\).
 

Detailed Description

template<class T>
class sdp::QRDecomposition< 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.

Constructor & Destructor Documentation

template<class T >
sdp::QRDecomposition< T >::QRDecomposition ( const std::vector< T > &  A,
int  m,
int  n,
double  sing_eps = 1e-10 
)
inline

Initializes an instance by computing the QR decomposition.

Parameters
Ais the input matrix as a vector in column-major order.
mnumber of rows in A.
nnumber of columns in A.
sing_epsis 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.
Exceptions
ValueErrorif there are less rows than columns.

Member Function Documentation

template<class T >
int sdp::QRDecomposition< T >::perm ( int  j) const
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).

template<class T >
int sdp::QRDecomposition< T >::rank ( ) const
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.

template<class T >
const T& sdp::QRDecomposition< T >::scaling_factor ( ) const
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.


The documentation for this class was generated from the following file: