Magnitude

Computes the magnitudes of the elements of a complex vector.

Syntax

IppStatus ippsMagnitude_32f(const Ipp32f* pSrcRe, const Ipp32f* pSrcIm, Ipp32f* pDst, int len);

IppStatus ippsMagnitude_64f(const Ipp64f* pSrcRe, const Ipp64f* pSrcIm, Ipp64f* pDst, int len);

IppStatus ippsMagnitude_32fc(const Ipp32fc* pSrc, Ipp32f* pDst, int len);

IppStatus ippsMagnitude_64fc(const Ipp64fc* pSrc, Ipp64f* pDst, int len);

IppStatus ippsMagnitude_16s32f(const Ipp16s* pSrcRe, const Ipp16s* pSrcIm, Ipp32f* pDst, int len);

IppStatus ippsMagnitude_16sc32f(const Ipp16sc* pSrc, Ipp32f* pDst, int len);

IppStatus ippsMagnitude_16s_Sfs(const Ipp16s* pSrcRe, const Ipp16s* pSrcIm, Ipp16s* pDst, int len, int scaleFactor);

IppStatus ippsMagnitude_16sc_Sfs(const Ipp16sc* pSrc, Ipp16s* pDst, int len, int scaleFactor);

IppStatus ippsMagnitude_32sc_Sfs(const Ipp32sc* pSrc, Ipp32s* pDst, int len, int scaleFactor);

Parameters

pSrc

Pointer to the source vector.

pSrcRe

Pointer to the vector with the real parts of complex elements.

pSrcIm

Pointer to the vector with the imaginary parts of complex elements.

pDst

Pointer to the destination vector.

len

Number of elements in the vector

scaleFactor

Scale factor, refer to Integer Scaling.

Description

The function ippsMagnitude is declared in the ipps.h file. The complex flavor of this function computes the element-wise magnitude of the complex vector pSrc and stores the result in pDst. The element-wise magnitude is defined by the formula:

magn[n] = (pSrc[n].re2 + pSrc[n].im2)1/2

The real flavor of the function ippsMagnitude computes the element-wise magnitude of the complex vector whose real and imaginary components are specified in the vectors pSrcRe and pSrcIm, respectively, and stores the result in pDst. The element-wise magnitude is defined by the formula:

magn[n] = (pSrcRe[n]2 + pSrcIm[n]2)1/2

The example below shows how the function ippsMagnitude is used to verify the identity sin2x + cos2x = 1.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error when any of the specified pointers is NULL.

ippStsSizeErr

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

Using the Function ippsMagnitude

void magn(void) {
      Ipp64f x[6], magn[4];
      int n;
      for (n = 0; n<6; ++n) x[n] = sin(IPP_2PI * n / 8);
      ippsMagnitude_64f(x, x+2, magn, 4);
      printf_64f(“magn =”, magn, 4, ippStsNoErr);
}
Output: 
    magn =  1.000000 1.000000 1.000000 1.000000
Matlab* Analog: 
    >> n = 0:9; x = sin(2*pi*n/8); z = [x(1:8)+j*x(3:10)]; abs(z(1:4))

Submit feedback on this help topic

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