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

CartToPolar

Converts the elements of a complex vector to polar coordinate form.

Syntax

IppStatus ippsCartToPolar_32f(const Ipp32f* pSrcRe, const Ipp32f* pSrcIm, Ipp32f* pDstMagn, Ipp32f* pDstPhase, int len);

IppStatus ippsCartToPolar_64f(const Ipp64f* pSrcRe, const Ipp64f* pSrcIm, Ipp64f* pDstMagn, Ipp64f* pDstPhase, int len);

IppStatus ippsCartToPolar_32fc(const Ipp32fc* pSrc, Ipp32f* pDstMagn, Ipp32f* pDstPhase, int len);

IppStatus ippsCartToPolar_64fc(const Ipp64fc* pSrc, Ipp64f* pDstMagn, Ipp64f* pDstPhase, int len);

IppStatus ippsCartToPolar_16sc_Sfs(const Ipp16sc* pSrc, Ipp16s* pDstMagn, Ipp16s* pDstPhase, int len, int magnScaleFactor, int phaseScaleFactor);

Include Files

ipps.h

Domain Dependencies

Headers: ippcore.h, ippvm.h

Libraries: ippcore.lib, ippvm.lib

Parameters

pSrc

Pointer to the source vector.

pSrcRe

Pointer to the source vector which stores the real components of Cartesian X,Y pairs.

pSrcIm

Pointer to the source vector which stores the imaginary components of Cartesian X,Y pairs.

pDstMagn

Pointer to the vector which stores the magnitude (radius) component of the elements of the vector pSrc.

pDstPhase

Pointer to the vector which stores the phase (angle) component of the elements of the vector pSrc in radians. Phase values are in the range (-π, π].

len

Number of elements in the vector.

magnScaleFactor

Integer scale factor for the magnitude component, refer to Integer Scaling.

phaseScaleFactor

Integer scale factor for the phase component, refer to Integer Scaling.

Description

This function converts the elements of a complex input vector pSrcor the complex input vector whose real and imaginary components are specified in the vectors pSrcRe and pSrcIm, respectively, to polar coordinate form, and stores the magnitude (radius) component of each element in the vector pDstMagn and the phase (angle) component of each element in the vector pDstPhase.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error when at least one of the specified pointers is NULL.

ippStsSizeErr

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

Example

/*******************************************************************************
* Copyright 2015 Intel Corporation.
*
*
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by
* the express license under which they were provided to you ('License'). Unless the License provides otherwise,
* you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related
* documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than
* those that are expressly stated in the License.
*******************************************************************************/

#include <stdio.h>
#include "ipp.h"
#include <math.h>

/* Next two defines are created to simplify code reading and understanding */
#define EXIT_MAIN exitLine:                                  /* Label for Exit */
#define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) Integrated Performance Primitives (Intel(R) IPP) function returned status different from ippStsNoErr */

/* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status  */

int main()
{
    int i;
    IppStatus status;
    Ipp64f cart[6], magn[4], phase[4];
    for (i = 0; i<6; ++i) cart[i] = sin(IPP_2PI * i / 8);

    printf("Source:\n");
    printf("\nre= ");
    for (i = 0; i < 4; i++) printf("%f ", cart[i]);
    printf("\nim= ");
    for (i = 2; i < 6; i++) printf("%f ", cart[i]);

    check_sts(status = ippsCartToPolar_64f(cart, cart + 2, magn, phase, 4));

    printf("\nResult:");
    printf("\nmagn= ");
    for (i = 0; i < 4; i++) printf("%f ", magn[i]);
    printf("\nphase= ");
    for (i = 0; i < 4; i++) printf("%f ", phase[i]);

EXIT_MAIN
    printf("\nExit status %d (%s)\n", (int)status, ippGetStatusString(status));
    return (int)status;
}