CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
Loading...
Searching...
No Matches
cla3p::PartialQR< T_Matrix > Class Template Reference

Partial Pivoted QR Decomposition for rank reduction algorithms. More...

Public Member Functions

 PartialQR ()
 Constructs an uninitialized partial QR object.
 PartialQR (int_t m, int_t n)
 Constructs a partial QR object with pre-allocated buffers.
 ~PartialQR ()
 Destroys the partial QR decomposition object.
void clear ()
 Clears all decomposition results and resets the object.
void reserve (int_t m, int_t n)
 Pre-allocates buffers for decomposition.
real_t cutTolerance () const
 Retrieves the singular value tolerance threshold.
void setCutTolerance (real_t tol)
 Configures the singular value tolerance threshold.
void decompose (const T_Matrix &mat)
 Initiates the partial QR decomposition.
void resume (bool ignoreTol=false)
 Resumes the partial QR decomposition.
int_t performDecompositionStep ()
 Performs a single decomposition step.
int_t totalColumnsProcessed () const
 Retrieves the count of processed columns.
const T_Matrix & R () const
 Retrieves the upper triangular matrix.
const T_Vector & tau () const
 Retrieves the Householder reflection coefficients.
const prm::PiMatrixP () const
 Retrieves the column pivoting permutation matrix.
const T_Matrix & elementaryReflectors () const
 Retrieves the elementary Householder reflector matrix.
bool transFlag () const
 Determines if input matrix was transposed.
void fillMatrixR (int_t numRanks=0)
 Extracts the upper triangular portion to form matrix \( R \).

Detailed Description

template<typename T_Matrix>
class cla3p::PartialQR< T_Matrix >

Partial Pivoted QR Decomposition for rank reduction algorithms.

Template Parameters
T_MatrixThe dense matrix type to decompose.

This class implements a partial (stopped) QR decomposition with column pivoting, useful for low-rank approximation and rank reduction processes. The algorithm processes the matrix incrementally, stopping when singular values fall below a specified tolerance threshold. The input matrix is automatically transposed as needed to ensure tall-matrix orientation ( \( m \geq n \)).

Constructor & Destructor Documentation

◆ PartialQR() [1/2]

template<typename T_Matrix>
cla3p::PartialQR< T_Matrix >::PartialQR ( )

Constructs an uninitialized partial QR object.

Initializes an empty partial QR object with no allocated memory for decomposition results.

◆ PartialQR() [2/2]

template<typename T_Matrix>
cla3p::PartialQR< T_Matrix >::PartialQR ( int_t m,
int_t n )

Constructs a partial QR object with pre-allocated buffers.

Initializes the partial QR decomposition object and allocates internal buffers to accommodate matrices up to the specified dimensions.

Parameters
[in]mThe maximum number of matrix rows.
[in]nThe maximum number of matrix columns.

◆ ~PartialQR()

template<typename T_Matrix>
cla3p::PartialQR< T_Matrix >::~PartialQR ( )

Destroys the partial QR decomposition object.

Releases all allocated memory and clears internal data structures.

Member Function Documentation

◆ clear()

template<typename T_Matrix>
void cla3p::PartialQR< T_Matrix >::clear ( )

Clears all decomposition results and resets the object.

Deallocates decomposition results and returns the object to its default state.

◆ reserve()

template<typename T_Matrix>
void cla3p::PartialQR< T_Matrix >::reserve ( int_t m,
int_t n )

Pre-allocates buffers for decomposition.

Allocates internal buffers to accommodate matrices with up to m rows and n columns. This avoids memory reallocation during subsequent decompositions.

Parameters
[in]mThe maximum number of matrix rows to support.
[in]nThe maximum number of matrix columns to support.

◆ cutTolerance()

template<typename T_Matrix>
real_t cla3p::PartialQR< T_Matrix >::cutTolerance ( ) const

Retrieves the singular value tolerance threshold.

Returns the relative tolerance parameter used to determine which columns are kept in the partial QR decomposition. Diagonal elements \( R_{i,i} \) are retained if \( |R_{i,i}| > |R_{0,0}| \cdot \text{cutTolerance}() \).

Returns
The current cutoff tolerance value.

◆ setCutTolerance()

template<typename T_Matrix>
void cla3p::PartialQR< T_Matrix >::setCutTolerance ( real_t tol)

Configures the singular value tolerance threshold.

Sets the relative tolerance parameter that determines stopping condition. Diagonal elements \( R_{i,i} \) are retained if \( |R_{i,i}| > |R_{0,0}| \cdot \text{tol} \).

Parameters
[in]tolThe desired cutoff tolerance value.

◆ decompose()

template<typename T_Matrix>
void cla3p::PartialQR< T_Matrix >::decompose ( const T_Matrix & mat)

Initiates the partial QR decomposition.

Begins column-wise QR decomposition with column pivoting, stopping when the tolerance criterion \( |R_{i,i}| > |R_{0,0}| \cdot \text{cutTolerance}() \) is violated.

Parameters
[in]matThe matrix to decompose.

◆ resume()

template<typename T_Matrix>
void cla3p::PartialQR< T_Matrix >::resume ( bool ignoreTol = false)

Resumes the partial QR decomposition.

Continues the decomposition from where decompose() or the previous resume() stopped. The decomposition proceeds until the tolerance criterion \( |R_{i,i}| > |R_{0,0}| \cdot \text{cutTolerance}() \) is violated, or all columns are processed if ignoreTol is true.

Parameters
[in]ignoreTolIf true, ignores the tolerance criterion and decomposes all remaining columns.

◆ performDecompositionStep()

template<typename T_Matrix>
int_t cla3p::PartialQR< T_Matrix >::performDecompositionStep ( )

Performs a single decomposition step.

Executes one decomposition step with an automatically determined block size.

Returns
The number of columns processed in this decomposition step.

◆ totalColumnsProcessed()

template<typename T_Matrix>
int_t cla3p::PartialQR< T_Matrix >::totalColumnsProcessed ( ) const

Retrieves the count of processed columns.

Returns the total number of columns processed so far throughout the partial QR decomposition.

Returns
The total number of columns processed.

◆ R()

template<typename T_Matrix>
const T_Matrix & cla3p::PartialQR< T_Matrix >::R ( ) const

Retrieves the upper triangular matrix.

Returns the matrix \( R \) calculated so far in the partial QR decomposition process.

Returns
A constant reference to the upper triangular matrix \( R \) in general form.

◆ tau()

template<typename T_Matrix>
const T_Vector & cla3p::PartialQR< T_Matrix >::tau ( ) const

Retrieves the Householder reflection coefficients.

Returns the vector \( \tau \) of size \( \min(m,n) \) containing the scalar factors for elementary Householder reflectors.

Returns
A constant reference to the Householder scalar coefficient vector.

◆ P()

template<typename T_Matrix>
const prm::PiMatrix & cla3p::PartialQR< T_Matrix >::P ( ) const

Retrieves the column pivoting permutation matrix.

Returns the permutation matrix \( P \) that encodes the column pivots applied during the partial QR decomposition process.

Returns
A constant reference to the column pivoting permutation matrix.

◆ elementaryReflectors()

template<typename T_Matrix>
const T_Matrix & cla3p::PartialQR< T_Matrix >::elementaryReflectors ( ) const

Retrieves the elementary Householder reflector matrix.

Returns a matrix containing the elementary Householder vectors used to implicitly represent the orthogonal transformation matrix from the QR decomposition.

Returns
A constant reference to the elementary reflector matrix.

◆ transFlag()

template<typename T_Matrix>
bool cla3p::PartialQR< T_Matrix >::transFlag ( ) const

Determines if input matrix was transposed.

Indicates whether the input matrix was automatically conjugate-transposed during initialization to achieve tall-matrix orientation.

Returns
true if the matrix was transposed, false otherwise.

◆ fillMatrixR()

template<typename T_Matrix>
void cla3p::PartialQR< T_Matrix >::fillMatrixR ( int_t numRanks = 0)

Extracts the upper triangular portion to form matrix \( R \).

Constructs matrix \( R \) from the elementary reflector matrix, optionally keeping only the first numRanks columns.

Parameters
[in]numRanksThe number of columns to retain (0 means all columns).