NumericAL
A header-only C++20 lexer built on REAL
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
numerical::pivoted_qr_decomposition< T > Class Template Reference

A QR factorisation with column pivoting A P = Q R of an m × n matrix, as scipy.linalg.qr(a, pivoting=True) (LAPACK's geqp3): at each step the column of largest remaining norm moved first, so R's diagonal does not grow in modulus down the diagonal and reveals A's numerical rank; the norms downdated as LAPACK's laqp2 downdates them, recomputed where the downdate has lost too much (√ε). Householder reflectors as larfg forms them; R's diagonal then made real and non-negative, as qr_decomposition's (Q's columns taking the phases), where LAPACK's may be negative. More...

#include <factorizations.hpp>

Public Member Functions

 pivoted_qr_decomposition (const matrix< T > &a, qr_mode mode=qr_mode::reduced)
 Factorises a: Q m × k and R k × n (k = min(m, n)), or Q m × m and R m × n (mode complete).
 
const matrix< T > & q () const noexcept
 Q, orthonormal columns: m × k, or m × m complete.
 
const matrix< T > & r () const noexcept
 R, upper trapezoidal, its diagonal real, non-negative and not increasing: k × n, or m × n.
 
const std::vector< std::size_t > & permutation () const noexcept
 The column permutation: column j of A P is column permutation()[j] of A, as SciPy's P.
 

Private Member Functions

std::size_t factor_block (buffer< T > &w, std::size_t m, std::size_t n, std::size_t start, std::size_t width, buffer< double > &current, buffer< double > &reference, std::vector< buffer< T > > &reflectors, std::vector< T > &taus)
 Up to width steps from column start of the column-major m × n w, as LAPACK's laqps: the reflections kept aside in F (A ← A − V Fᴴ, F(j, ·) = τ A(:, j)ᴴ v less the earlier reflectors' share), each step's pivot column and pivot row brought up to date alone, the rest of the matrix by one product at the end; a column whose norm downdate lost too much (√ε) ends the block, its norm recomputed after the product.
 

Private Attributes

matrix< T > q_
 Q.
 
matrix< T > r_
 R.
 
std::vector< std::size_t > permutation_
 P, by its columns' origins.
 

Static Private Attributes

static constexpr std::size_t pivoted_qr_block {32}
 geqp3's block of columns (NB).
 
static constexpr std::size_t pivoted_qr_crossover {128}
 The columns geqp3 leaves to the unblocked steps (NX).
 
static constexpr std::size_t pivoted_qr_band {16}
 The columns one thread takes of a block's updates.
 

Detailed Description

template<double_field T>
class numerical::pivoted_qr_decomposition< T >

A QR factorisation with column pivoting A P = Q R of an m × n matrix, as scipy.linalg.qr(a, pivoting=True) (LAPACK's geqp3): at each step the column of largest remaining norm moved first, so R's diagonal does not grow in modulus down the diagonal and reveals A's numerical rank; the norms downdated as LAPACK's laqp2 downdates them, recomputed where the downdate has lost too much (√ε). Householder reflectors as larfg forms them; R's diagonal then made real and non-negative, as qr_decomposition's (Q's columns taking the phases), where LAPACK's may be negative.

Definition at line 4016 of file factorizations.hpp.

Constructor & Destructor Documentation

◆ pivoted_qr_decomposition()

template<double_field T>
numerical::pivoted_qr_decomposition< T >::pivoted_qr_decomposition ( const matrix< T > &  a,
qr_mode  mode = qr_mode::reduced 
)
inlineexplicit

Factorises a: Q m × k and R k × n (k = min(m, n)), or Q m × m and R m × n (mode complete).

Exceptions
non_finite_errorIf an entry is infinite or NaN.

Definition at line 4025 of file factorizations.hpp.

Member Function Documentation

◆ factor_block()

template<double_field T>
std::size_t numerical::pivoted_qr_decomposition< T >::factor_block ( buffer< T > &  w,
std::size_t  m,
std::size_t  n,
std::size_t  start,
std::size_t  width,
buffer< double > &  current,
buffer< double > &  reference,
std::vector< buffer< T > > &  reflectors,
std::vector< T > &  taus 
)
inlineprivate

Up to width steps from column start of the column-major m × n w, as LAPACK's laqps: the reflections kept aside in F (A ← A − V Fᴴ, F(j, ·) = τ A(:, j)ᴴ v less the earlier reflectors' share), each step's pivot column and pivot row brought up to date alone, the rest of the matrix by one product at the end; a column whose norm downdate lost too much (√ε) ends the block, its norm recomputed after the product.

Returns
The steps taken.

Definition at line 4161 of file factorizations.hpp.

◆ permutation()

template<double_field T>
const std::vector< std::size_t > & numerical::pivoted_qr_decomposition< T >::permutation ( ) const
inlinenoexcept

The column permutation: column j of A P is column permutation()[j] of A, as SciPy's P.

Definition at line 4143 of file factorizations.hpp.

◆ q()

template<double_field T>
const matrix< T > & numerical::pivoted_qr_decomposition< T >::q ( ) const
inlinenoexcept

Q, orthonormal columns: m × k, or m × m complete.

Definition at line 4131 of file factorizations.hpp.

◆ r()

template<double_field T>
const matrix< T > & numerical::pivoted_qr_decomposition< T >::r ( ) const
inlinenoexcept

R, upper trapezoidal, its diagonal real, non-negative and not increasing: k × n, or m × n.

Definition at line 4137 of file factorizations.hpp.

Member Data Documentation

◆ permutation_

template<double_field T>
std::vector<std::size_t> numerical::pivoted_qr_decomposition< T >::permutation_
private

P, by its columns' origins.

Definition at line 4289 of file factorizations.hpp.

◆ pivoted_qr_band

template<double_field T>
constexpr std::size_t numerical::pivoted_qr_decomposition< T >::pivoted_qr_band {16}
staticconstexprprivate

The columns one thread takes of a block's updates.

Definition at line 4152 of file factorizations.hpp.

◆ pivoted_qr_block

template<double_field T>
constexpr std::size_t numerical::pivoted_qr_decomposition< T >::pivoted_qr_block {32}
staticconstexprprivate

geqp3's block of columns (NB).

Definition at line 4150 of file factorizations.hpp.

◆ pivoted_qr_crossover

template<double_field T>
constexpr std::size_t numerical::pivoted_qr_decomposition< T >::pivoted_qr_crossover {128}
staticconstexprprivate

The columns geqp3 leaves to the unblocked steps (NX).

Definition at line 4151 of file factorizations.hpp.

◆ q_

template<double_field T>
matrix<T> numerical::pivoted_qr_decomposition< T >::q_
private

Q.

Definition at line 4287 of file factorizations.hpp.

◆ r_

template<double_field T>
matrix<T> numerical::pivoted_qr_decomposition< T >::r_
private

R.

Definition at line 4288 of file factorizations.hpp.


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