ocmath_qr

 

Description

Get matrix decomposition that can be used to solve linear systems of equations.

Syntax

int ocmath_qr( const double * pMatI, double * pQ, double * pR, int rows, int cols )

Parameters

pMatI
[input] pointer to the original matrix
pQ
[output] pointer to matrix Q
pR
[output] pointer to matrix R
rows
[input] row number of the original matrix
cols
[input] column number of the original matrix

Return

0 : success

-1 : rows or cols is not positive

Examples

EX1

void ocmath_qr_ex1()
{
    matrix mat0={{2,3,5,7},{11,13,17,19},{23,29,31,37}};
    matrix matQ,matR;
    
    int m = mat0.GetNumRows();
    int n = mat0.GetNumCols();
        matQ.SetSize(m, m);
        matR.SetSize(m, n);
    int iRet = ocmath_qr(mat0, matQ, matR, m, n);
}

Remark

QR decomposition. Given a Matrix A, its QR-decomposition is of the form A = QR.

where R is an upper Triangular Matrix and Q is an Orthogonal Matrix, i.e., one satisfying Q'Q = I where I is the Identity Matrix.

This matrix decomposition can be used to solve linear systems of equations.

See Also

header to Include

origin.h

Reference