L2Norm

Computes vector L2 norm.

Syntax

Case 1: Vector operation

IppStatus ippmL2Norm_v_32f(const Ipp32f* pSrc, int srcStride2, Ipp32f* pDst, int len);

IppStatus ippmL2Norm_v_64f(const Ipp64f* pSrs, int srcStride2, Ipp64f* pDst, int len);

IppStatus ippmL2Norm_v_32f_P(const Ipp32f** ppSrc, int srcRoiShift, Ipp32f* pDst, int len);

IppStatus ippmL2Norm_v_64f_P(const Ipp64f** ppSrc, int srcRoiShift, Ipp64f* pDst, int len);

Case 2: Vector array operation

IppStatus ippmL2Norm_va_32f(const Ipp32f* pSrc, int srcStride0, int srcStride2, Ipp32f* pDst, int len, int count);

IppStatus ippmL2Norm_va_64f(const Ipp64f* pSrc, int srcStride0, int srcStride2, Ipp64f* pDst, int len, int count);

IppStatus ippmL2Norm_va_32f_P(const Ipp32f** ppSrc, int srcRoiShift, int srcStride0, Ipp32f* pDst, int len, int count);

IppStatus ippmL2Norm_va_64f_P(const Ipp64f** ppSrc, int srcRoiShift, int srcStride0, Ipp64f* pDst, int len, int count);

IppStatus ippmL2Norm_va_32f_L(const Ipp32f** ppSrc, int srcRoiShift, int srcStride2, Ipp32f* pDst, int len, int count);

IppStatus ippmL2Norm_va_64f_L(const Ipp64f** ppSrc, int srcRoiShift, int srcStride2, Ipp64f* pDst, int len, int count);

Parameters

pSrc, ppSrc
Pointer to the source vector or vector array.
srcStride0
Stride between the vectors in the source vector array.
srcStride2
Stride between the elements in the source vector(s).
srcRoiShift
ROI shift in the source vector(s).
pDst
Pointer to the destination value or array of values.
len
Vector length.
count
Number of vectors in the array.

Description

The function ippmL2Norm is declared in the ippm.h header file. The function calculates L2 norm of the source vector and stores the result in pDst. The destination value is the square root of the sum of all the squared elements in the source vector, or

The following example demonstrates how to use the function ippmL2Norm_va_32f_P. For more information, see also examples in Getting Started.

ippmL2Norm_va_32f_P  

IppStatus l2norm_va_32f_P(void) {
    /* Source data */
    Ipp32f src[3*4] = { 1.1f, 2.1f, 3.1f, 4.1f,
                        1.2f, 2.2f, 3.2f, 4.2f,
                        1.3f, 2.3f, 3.3f, 4.3f };
 
    /*
    // The first operand is 4 vector-columns with length=3
    // Pointer description:
    // ppSrc1[0] pointer to the first element of the first column
    // ppSrc1[1] pointer to the second element of the first column
    // ppSrc1[2] pointer to the third element  of the first column
    */
    Ipp32f* ppSrc[3] = { src, src+4, src+8 };
    int srcRoiShift = 0;
    int srcStride0 = sizeof(Ipp32f); /* Stride between columns */
    int length = 3;

    /*
    // Destination is 4 values
    */
    Ipp32f pDst[4];
    int count = 4;

    IppStatus status = ippmL2Norm_va_32f_P((const Ipp32f**)ppSrc,
       srcRoiShift, srcStride0, pDst, length, count);
 
    /*
    // It is recommended to check return status 
    // to detect wrong input parameters, if any  
    */
    if (status == ippStsNoErr) {
        printf_va_Ipp32f("Dst is 4 values:", pDst, 4, 1, status);
    } else {
        printf("Function returns status: %s \n", ippGetStatusString(status));
    }
    return status;
}
 

The program above produces the following output:

Dst is 4 values:

2.083267  3.813135  5.544366  7.275988

Return Values

ippStsOk

Returns no error.

ippStsNullPtrErr

Returns an error when at least one input pointer is NULL.

ippStsSizeErr

Returns an error when the input size parameter is equal to 0.

ippStsStrideMatrixErr

Returns an error when the stride value is not positive or not divisible by size of data type.

ippStsRoiShiftMatrixErr

Returns an error when the roiShift value is negative or not divisible by size of data type.

ippStsCountMatrixErr

Returns an error when the count value is less or equal to zero.

Submit feedback on this help topic

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