NormDiff

Computes the C, L1, L2, or L2Sqr norm of two vectors' difference.

Syntax

IppStatus ippsNormDiff_Inf_32f(const Ipp32f* pSrc1, const Ipp32f* pSrc2, int len, Ipp32f* pNorm);

IppStatus ippsNormDiff_Inf_64f(const Ipp64f* pSrc1, const Ipp64f* pSrc2, int len, Ipp64f* pNorm);

IppStatus ippsNormDiff_Inf_16s32f(const Ipp16s* pSrc1, const Ipp16s* pSrc2, int len, Ipp32f* pNorm);

IppStatus ippsNormDiff_Inf_32fc32f(const Ipp32fc* pSrc1, const Ipp32fc* pSrc2, int len, Ipp32f* pNorm);

IppStatus ippsNormDiff_Inf_64fc64f(const Ipp64fc* pSrc1, const Ipp64fc* pSrc2, int len, Ipp64f* pNorm);

IppStatus ippsNormDiff_Inf_16s32s_Sfs(const Ipp16s* pSrc1, const Ipp16s* pSrc2, int len, Ipp32s* pNorm, int scaleFactor);

IppStatus ippsNormDiff_L1_32f(const Ipp32f* pSrc1, const Ipp32f* pSrc2, int len, Ipp32f* pNorm);

IppStatus ippsNormDiff_L1_64f(const Ipp64f* pSrc1, const Ipp64f* pSrc2, int len, Ipp64f* pNorm);

IppStatus ippsNormDiff_L1_16s32f(const Ipp16s* pSrc1, const Ipp16s* pSrc2, int len, Ipp32f* pNorm);

IppStatus ippsNormDiff_L1_32fc64f(const Ipp32fc* pSrc1, const Ipp32fc* pSrc2, int len, Ipp64f* pNorm);

IppStatus ippsNormDiff_L1_64fc64f(const Ipp64fc* pSrc1, const Ipp64fc* pSrc2, int len, Ipp64f* pNorm);

IppStatus ippsNormDiff_L1_16s32s_Sfs(const Ipp16s* pSrc1, const Ipp16s* pSrc2, int len, Ipp32s* pNorm, int scaleFactor);

IppStatus ippsNormDiff_L1_16s64s_Sfs(const Ipp16s* pSrc1, const Ipp16s* pSrc2, int len, Ipp64s* pNorm, int scaleFactor);

IppStatus ippsNormDiff_L2_32f(const Ipp32f* pSrc1, const Ipp32f* pSrc2, int len, Ipp32f* pNorm);

IppStatus ippsNormDiff_L2_64f(const Ipp64f* pSrc1, const Ipp64f* pSrc2, int len, Ipp64f* pNorm);

IppStatus ippsNormDiff_L2_16s32f(const Ipp16s* pSrc1, const Ipp16s* pSrc2, int len, Ipp32f* pNorm);

IppStatus ippsNormDiff_L2_32fc64f(const Ipp32fc* pSrc1, const Ipp32fc* pSrc2, int len, Ipp64f* pNorm);

IppStatus ippsNormDiff_L2_64fc64f(const Ipp64fc* pSrc1, const Ipp64fc* pSrc2, int len, Ipp64f* pNorm);

IppStatus ippsNormDiff_L2_16s32s_Sfs(const Ipp16s* pSrc1, const Ipp16s* pSrc2, int len, Ipp32s* pNorm, int scaleFactor);

IppStatus ippsNormDiff_L2Sqr_16s64s_Sfs(const Ipp16s* pSrc1, const Ipp16s* pSrc2, int len, Ipp64s* pNorm, int scaleFactor);

Parameters

pSrc1, pSrc2

Pointers to the two source vectors; pSrc2 can be NULL.

pNorm

Pointer to the output result.

len

Number of elements in the vector.

scaleFactor

Scale factor, refer to Integer Scaling.

Description

The function ippsNorm is declared in the ipps.h file. This function computes the C, L1, L2, or L2Sqr norm of the source vectors' difference, and stores the result in pNorm.

ippsNormDiff_Inf. The function ippsNormDiff_Inf computes the C norm defined by the formula:



ippsNormDiff_L1. The function ippsNormDiff_L1 computes the L1 norm defined by the formula:



ippsNormDiff_L2. The function ippsNormDiff_L2 computes the L2 norm defined by the formula:



ippsNormDiff_L2Sqr. The function ippsNormDiff_L2Sqr computes the L2Sqr norm defined as square of the L2 norm.

Functions with Sfs suffixes perform scaling of the result value in accordance with the scaleFactor value.

The example below shows how to use the function ippsNormDiff.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error when the pSrc1, pSrc2, or pNorm pointer is NULL.

ippStsSizeErr

Indicates an error when len is less than or equal to 0.

Using the ippsNorm Function

int norm( void ) {
      Ipp16s x[LEN];
      Ipp32f Norm[3];
      IppStatus st;
      int i;
      for( i=0; i<LEN; ++i ) x[i] = (Ipp16s)rand();
      ippsNormDiff_Inf_16s32f( x, 0, LEN, Norm );
      ippsNormDiff_L1_16s32f( x, 0, LEN, Norm+1 );
      st = ippsNormDiff_L2_16s32f( x, 0, LEN, Norm+2 );
      printf_32f(“Norm (oo,L1,L2) =”, Norm, 3, st );
      return Norm[2] <= Norm[1] && Norm[1] <= LEN*Norm[0];
}
Output: 
    Norm (oo,L1,L2) =  31993.000000 1526460.000000 180270.781250
Matlab* analog: 
    >> x = 32767*rand(1,100);norm(x,inf),norm(x,1),norm(x,2)

Submit feedback on this help topic

Copyright © 2000 - 2011, Intel Corporation. All rights reserved.