ocmath_pinv

 

Description

pseudoinverse

Syntax

int ocmath_pinv( const double * pMatI, double * pPinv, int m, int n, double dTol = -1 )

Parameters

pMatI
[input] pointer to original matrix
pPinv
[output] pointer to pseudoinverse matrix
m
[input] row number of the original matrix
n
[input] col number of the original matrix
dTol
[input] The computation is based on SVD and any singular values less than a tolerance are treated as zero. The default tolerance is MAX(SIZE(A)) * NORM(A) * EPS.

Return

Returns 0 if success, 1 if not.

Examples

EX1

void ocmath_pinv_ex1()
{
    matrix mat0={{2,3,5},{7,11,13}};
    matrix mat1;
    int m = mat0.GetNumRows();
    int n = mat0.GetNumCols();
    mat1.SetSize(n,m);
    int iRet = ocmath_pinv(mat0, mat1, m, n);
}

Remark

Pseudoinverse, the same as Matlab function pinv()

See Also

header to Include

origin.h

Reference