Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference

ID 790148
Date 6/24/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

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_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_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_L2Sqr_16s64s_Sfs(const Ipp16s* pSrc1, const Ipp16s* pSrc2, int len, Ipp64s* pNorm, int scaleFactor);

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

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_16s32s_Sfs(const Ipp16s* pSrc1, const Ipp16s* pSrc2, int len, Ipp32s* pNorm, int scaleFactor);

Include Files

ipps.h

Domain Dependencies

Headers: ippcore.h, ippvm.h

Libraries: ippcore.lib, ippvm.lib

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

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.

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.

Example

The example below shows how to use the function ippsNormDiff.

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)