NMSIS-DSP  Version 1.2.0
NMSIS DSP Software Library
QR decomposition of a Matrix

Computes the QR decomposition of a matrix M using Householder algorithm. More...

Functions

riscv_status riscv_mat_qr_f16 (const riscv_matrix_instance_f16 *pSrc, const float16_t threshold, riscv_matrix_instance_f16 *pOutR, riscv_matrix_instance_f16 *pOutQ, float16_t *pOutTau, float16_t *pTmpA, float16_t *pTmpB)
 QR decomposition of a m x n half floating point matrix with m >= n. More...
 
riscv_status riscv_mat_qr_f32 (const riscv_matrix_instance_f32 *pSrc, const float32_t threshold, riscv_matrix_instance_f32 *pOutR, riscv_matrix_instance_f32 *pOutQ, float32_t *pOutTau, float32_t *pTmpA, float32_t *pTmpB)
 QR decomposition of a m x n floating point matrix with m >= n. More...
 
riscv_status riscv_mat_qr_f64 (const riscv_matrix_instance_f64 *pSrc, const float64_t threshold, riscv_matrix_instance_f64 *pOutR, riscv_matrix_instance_f64 *pOutQ, float64_t *pOutTau, float64_t *pTmpA, float64_t *pTmpB)
 QR decomposition of a m x n double floating point matrix with m >= n. More...
 

Detailed Description

Computes the QR decomposition of a matrix M using Householder algorithm.

\[ M = Q R \]

where Q is an orthogonal matrix and R is upper triangular. No pivoting strategy is used.

The returned value for R is using a format a bit similar to LAPACK : it is not just containing the matrix R but also the Householder reflectors.

The function is also returning a vector \(\tau\) that is containing the scaling factor for the reflectors.

Returned value R has the structure:

\[ \begin{pmatrix} r_{11} & r_{12} & \dots & r_{1n} \\ v_{12} & r_{22} & \dots & r_{2n} \\ v_{13} & v_{22} & \dots & r_{3n} \\ \vdots & \vdots & \ddots & \vdots \\ v_{1m} & v_{2(m-1)} & \dots & r_{mn} \\ \end{pmatrix} \]

where

\[ v_1 = \begin{pmatrix} 1 \\ v_{12} \\ \vdots \\ v_{1m} \\ \end{pmatrix} \]

is the first householder reflector.

The Householder Matrix is given by \(H_1\)

\[ H_1 = I - \tau_1 v_1 v_1^T \]

The Matrix Q is the product of the Householder matrices:

\[ Q = H_1 H_2 \dots H_n \]

The computation of the matrix Q by this function is optional.

And the matrix R, would be the returned value R without the householder reflectors:

\[ \begin{pmatrix} r_{11} & r_{12} & \dots & r_{1n} \\ 0 & r_{22} & \dots & r_{2n} \\ 0 & 0 & \dots & r_{3n} \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \dots & r_{mn} \\ \end{pmatrix} \]

Function Documentation

◆ riscv_mat_qr_f16()

riscv_status riscv_mat_qr_f16 ( const riscv_matrix_instance_f16 pSrc,
const float16_t  threshold,
riscv_matrix_instance_f16 pOutR,
riscv_matrix_instance_f16 pOutQ,
float16_t *  pOutTau,
float16_t *  pTmpA,
float16_t *  pTmpB 
)

QR decomposition of a m x n half floating point matrix with m >= n.

QR decomposition of a m x n floating point matrix with m >= n.

Parameters
[in]pSrcpoints to input matrix structure. The source matrix is modified by the function.
[in]thresholdnorm2 threshold.
[out]pOutRpoints to output R matrix structure of dimension m x n
[out]pOutQpoints to output Q matrix structure of dimension m x m (can be NULL)
[out]pOutTaupoints to Householder scaling factors of dimension n
[in,out]pTmpApoints to a temporary vector of dimension m.
[in,out]pTmpBpoints to a temporary vector of dimension m.
Returns
execution status
  • RISCV_MATH_SUCCESS : Operation successful
  • RISCV_MATH_SIZE_MISMATCH : Matrix size check failed
pOutQ is optional:
pOutQ can be a NULL pointer. In this case, the argument will be ignored and the output Q matrix won't be computed.
f16 implementation
The f16 implementation is not very accurate.
Norm2 threshold
For the meaning of this argument please refer to the Householder transform of a vector documentation

◆ riscv_mat_qr_f32()

riscv_status riscv_mat_qr_f32 ( const riscv_matrix_instance_f32 pSrc,
const float32_t  threshold,
riscv_matrix_instance_f32 pOutR,
riscv_matrix_instance_f32 pOutQ,
float32_t *  pOutTau,
float32_t *  pTmpA,
float32_t *  pTmpB 
)

QR decomposition of a m x n floating point matrix with m >= n.

Parameters
[in]pSrcpoints to input matrix structure. The source matrix is modified by the function.
[in]thresholdnorm2 threshold.
[out]pOutRpoints to output R matrix structure of dimension m x n
[out]pOutQpoints to output Q matrix structure of dimension m x m (can be NULL)
[out]pOutTaupoints to Householder scaling factors of dimension n
[in,out]pTmpApoints to a temporary vector of dimension m.
[in,out]pTmpBpoints to a temporary vector of dimension m.
Returns
execution status
  • RISCV_MATH_SUCCESS : Operation successful
  • RISCV_MATH_SIZE_MISMATCH : Matrix size check failed
pOutQ is optional:
pOutQ can be a NULL pointer. In this case, the argument will be ignored and the output Q matrix won't be computed.
Norm2 threshold
For the meaning of this argument please refer to the Householder transform of a vector documentation

◆ riscv_mat_qr_f64()

riscv_status riscv_mat_qr_f64 ( const riscv_matrix_instance_f64 pSrc,
const float64_t  threshold,
riscv_matrix_instance_f64 pOutR,
riscv_matrix_instance_f64 pOutQ,
float64_t *  pOutTau,
float64_t *  pTmpA,
float64_t *  pTmpB 
)

QR decomposition of a m x n double floating point matrix with m >= n.

QR decomposition of a m x n floating point matrix with m >= n.

Parameters
[in]pSrcpoints to input matrix structure. The source matrix is modified by the function.
[in]thresholdnorm2 threshold.
[out]pOutRpoints to output R matrix structure of dimension m x n
[out]pOutQpoints to output Q matrix structure of dimension m x m (can be NULL)
[out]pOutTaupoints to Householder scaling factors of dimension n
[in,out]pTmpApoints to a temporary vector of dimension m.
[in,out]pTmpBpoints to a temporary vector of dimension m.
Returns
execution status
  • RISCV_MATH_SUCCESS : Operation successful
  • RISCV_MATH_SIZE_MISMATCH : Matrix size check failed
pOutQ is optional:
pOutQ can be a NULL pointer. In this case, the argument will be ignored and the output Q matrix won't be computed.
Norm2 threshold
For the meaning of this argument please refer to the Householder transform of a vector documentation