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

ID 790148
Date 10/31/2024
Public
Document Table of Contents

Hypot

Computes a square root of sum of two squared elements.

Syntax

IppStatus ippsHypot_32f_A11 (const Ipp32f* pSrc1, const Ipp32f pSrc2, Ipp32f* pDst, Ipp32s len);

IppStatus ippsHypot_32f_A21 (const Ipp32f* pSrc1, const Ipp32f* pSrc2, Ipp32f* pDst, Ipp32s len);

IppStatus ippsHypot_32f_A24 (const Ipp32f* pSrc1, const Ipp32f* pSrc2, Ipp32f* pDst, Ipp32s len);

IppStatus ippsHypot_64f_A26 (const Ipp64f* pSrc1, const Ipp64f* pSrc2, Ipp64f* pDst, Ipp32s len);

IppStatus ippsHypot_64f_A50 (const Ipp64f* pSrc1, const Ipp64f* pSrc2, Ipp64f* pDst, Ipp32s len);

IppStatus ippsHypot_64f_A53 (const Ipp64f* pSrc1, const Ipp64f* pSrc2, Ipp64f* pDst, Ipp32s len);

Include Files

ippvm.h

Domain Dependencies

Headers: ippcore.h

Libraries: ippcore.lib

Parameters

pSrc1

Pointer to the first source vector.

pSrc2

Pointer to the second source vector.

pDst

Pointer to the destination vector.

len

Number of elements in the vectors.

Description

This function computes square of each element of the pSrc1 and pSrc2 vectors, sums corresponding elements, computes square roots of each sum and stores the result in the corresponding element of pDst.

For single precision data:

function flavor ippsHypot_32f_A11 guarantees 11 correctly rounded bits of significand, or at least 3 exact decimal digits;

function flavor ippsHypot_32f_A21 guarantees 21 correctly rounded bits of significand, or 4 ulps, or about 6 exact decimal digits;

function flavor ippsHypot_32f_A24 guarantees 24 correctly rounded bits of significand, including the implied bit, with the maximum guaranteed error within 1 ulp.

For double precision data:

function flavor ippsHypot_64f_A26 guarantees 26 correctly rounded bits of significand, or 6.7E+7 ulps, or approximately 8 exact decimal digits;

function flavor ippsHypot_64f_A50 guarantees 50 correctly rounded bits of significand, or 4 ulps, or approximately 15 exact decimal digits;

function flavor ippsHypot_64f_A53 guarantees 53 correctly rounded bits of significand, including the implied bit, with the maximum guaranteed error within 1 ulp.

The computation is performed as follows:

pDst[n] = ((pSrc1[n])2 + (pSrc2[n])2)1/2, 0 ≤ n < len.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error when pSrc1 or pSrc2 or pDst 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 ippsHypot.

IppStatus ippsHypot_32f_A21_sample(void) {
	const Ipp32f x1[4] = {0.483, 0.565, 0.776, 0.252}
	const Ipp32f x2[4] = {0.823, 0.991, 0.411, 0.692};
	Ipp32f y[4];
	IppStatus st = ippsHypot_32f_A21( x1, x2, y, 4 );
	
	printf(" ippsHypot_32f_A21:\n");
	printf(" x1 = %.3f %.3f %.3f %.3f \n", x1[0], x1[1], x1[2], x1[3]);
	printf(" x2 = %.3f %.3f %.3f %.3f \n", x2[0], x2[1], x2[2], x2[3]);
	printf(" y  = %.3f %.3f %.3f %.3f \n", y[0],  y[1],  y[2],  y[3]);
	return st;
}

Output:

 
ippsHypot_32f_A21:
x1 = 0.483 0.565 0.776 0.252
x2 = 0.823 0.991 0.411 0.692
y  = 0.954 1.141 0.878 0.736