Computes vector L2 norm.
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);
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.
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
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. |
Copyright © 2000 - 2011, Intel Corporation. All rights reserved.