2.1.17.6.6 ocmath_norm2


Description

General norm function, for matrix of nRows x nCols

Syntax

double ocmath_norm2( double * pData, uint nRows, uint nCols, int np )

Parameters

pData
[input] pointer to matrix data
nRows
[input] the size of row
nCols
[input] the size of column
np
[input] the types of matrix norms, see stats_type.h for more detail
NORM_LARGEST_SUM = 1  : the largest column sum of matrix or the 1-norm
NORM_LARGEST_SINGULAR = 2 : the largest SVD of matrix
NORM_INFINITY = 3  : the largest row sum of matrix
NORM_FROBEBINUS = 4  : the Frobenius-norm of matrix, sqrt(sum(diag(pData'*pData)))

Return

return the value according to the types of matrix norms, but if nRows or nCols < 1, return NANUM.

Examples

EX1

void ocmath_norm2_ex1()
{
    vector data = {52,234,564,2,3,64,3,546,435,4,5,3};//Generate data
    UINT row = 4, col = 3;//specify the size of row and column of data
    double large_sum = ocmath_norm2(data, row, col, NORM_LARGEST_SUM);// compute the largest sum of column
    printf("The largest sum is %g\n", large_sum);
}

Remark

See Also

ocmath_norm

Header to Include

origin.h

Reference