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

ID 790148
Date 3/22/2024
Public
Document Table of Contents

FFTFwd_CToC

Computes the forward fast Fourier transform (FFT) of a complex signal.

Syntax

Case 1: Not-in-place operation on real data type

IppStatus ippsFFTFwd_CToC_32f(const Ipp32f* pSrcRe, const Ipp32f* pSrcIm, Ipp32f* pDstRe, Ipp32f* pDstIm, const IppsFFTSpec_C_32f* pFFTSpec, Ipp8u* pBuffer);

IppStatus ippsFFTFwd_CToC_64f(const Ipp64f* pSrcRe, const Ipp64f* pSrcIm, Ipp64f* pDstRe, Ipp64f* pDstIm, const IppsFFTSpec_C_64f* pFFTSpec, Ipp8u* pBuffer);

Case 2: Not-in-place operation on complex data type

IppStatus ippsFFTFwd_CToC_32fc(const Ipp32fc* pSrc, Ipp32fc* pDst, const IppsFFTSpec_C_32fc* pFFTSpec, Ipp8u* pBuffer);

IppStatus ippsFFTFwd_CToC_64fc(const Ipp64fc* pSrc, Ipp64fc* pDst, const IppsFFTSpec_C_64fc* pFFTSpec, Ipp8u* pBuffer);

Case 3: In-place operation on real data type.

IppStatus ippsFFTFwd_CToC_32f_I(Ipp32f* pSrcDstRe, Ipp32f* pSrcDstIm, const IppsFFTSpec_C_32f* pFFTSpec, Ipp8u* pBuffer);

IppStatus ippsFFTFwd_CToC_64f_I(Ipp64f* pSrcDstRe, Ipp64f* pSrcDstIm, const IppsFFTSpec_C_64f* pFFTSpec, Ipp8u* pBuffer);

Case 4: In-place operation on complex data type.

IppStatus ippsFFTFwd_CToC_32fc_I(Ipp32fc* pSrcDst, const IppsFFTSpec_C_32fc* pFFTSpec, Ipp8u* pBuffer);

IppStatus ippsFFTFwd_CToC_64fc_I(Ipp64fc* pSrcDst, const IppsFFTSpec_C_64fc* pFFTSpec, Ipp8u* pBuffer);

Include Files

ipps.h

Domain Dependencies

Headers: ippcore.h, ippvm.h

Libraries: ippcore.lib, ippvm.lib

Parameters

pFFTSpec

Pointer to the FFT specification structure.

pSrc

Pointer to the input array containing complex values.

pDst

Pointer to the output array containing complex values.

pSrcRe

Pointer to the input array containing real parts of the signal.

pSrcIm

Pointer to the input array containing imaginary parts of the signal.

pDstRe

Pointer to the output array containing real parts of the signal.

pDstIm

Pointer to the output array containing imaginary parts of the signal.

pSrcDst

Pointer to the input and output array containing complex values (for the in-place operation).

pSrcDstRe

Pointer to the input and output array containing real parts of the signal (for the in-place operation).

pSrcDstIm

Pointer to the input and output array containing imaginary parts of the signal (for the in-place operation).

pBuffer

Pointer to the external work buffer.

Description

This function computes the forward FFT of a complex signal according to the following pFFTSpec specification parameters: the transform order, the normalization flag, and the specific code hint. Before calling these functions, you need to initialize the FFT specification structure using the ippsFFTInit_C function.

The functions using the complex data type, for example with the 32fc suffixes, process the input complex array pSrc and store the result in pDst. Their in-place flavors use the complex array pSrcDst.

The functions using the real data type and processing complex signals represented by separate real pSrcRe and imaginary pSrcIm parts, for example, with the 32f suffixes, store the result separately in pDstRe and pDstIm, respectively. Their in-place flavors use separate real and imaginary arrays pSrcDstRe and pSrcDstIm, respectively.

Use this function with the external work buffer pBuffer. Once the work buffer is allocated, it can be used for all following calls of the functions computing FFT. The use of an external buffer improves performance significantly, especially for the small size transforms.

The size of the external buffer must be previously computed by the function ippsFFTGetBufSize_C or ippsFFTGetSize_C.

The length of the FFT must be a power of 2.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error when one of the specified pointers with exception of pBuffer is NULL.

ippStsContextMatchErr

Indicates an error when the specification identifier pFFTSpec is incorrect.

ippStsMemAllocErr

Indicates an error when no memory is allocated.

Example

The code example below demonstrates how to use the ippsFFTGetSize, ippsFFTInit, and ippsFFTFwd_CToC functions.

void ippsFFT_32fc_example()
{
    Ipp32fc Src[32] = {
        {0.0, 1.0}, {2.0, 3.0}, {4.0, 5.0}, {6.0, 7.0},
        {0.0, 1.0}, {2.0, 3.0}, {4.0, 5.0}, {6.0, 7.0},
        {0.0, 1.0}, {2.0, 3.0}, {4.0, 5.0}, {6.0, 7.0},
        {0.0, 1.0}, {2.0, 3.0}, {4.0, 5.0}, {6.0, 7.0},
        {0.0, 1.0}, {2.0, 3.0}, {4.0, 5.0}, {6.0, 7.0},
        {0.0, 1.0}, {2.0, 3.0}, {4.0, 5.0}, {6.0, 7.0},
        {0.0, 1.0}, {2.0, 3.0}, {4.0, 5.0}, {6.0, 7.0},
        {0.0, 1.0}, {2.0, 3.0}, {4.0, 5.0}, {6.0, 7.0}
    };
    Ipp32fc Dst[32];

    int FFTOrder = 5;
    IppsFFTSpec_C_32fc *pSpec = 0;

    Ipp8u *pMemSpec = 0;
    Ipp8u *pMemInit = 0;
    Ipp8u *pMemBuffer = 0;

    int sizeSpec = 0;
    int sizeInit = 0;
    int sizeBuffer = 0;

    int flag = IPP_FFT_NODIV_BY_ANY;

    /// get sizes for required buffers
    ippsFFTGetSize_C_32fc(FFTOrder, flag, ippAlgHintNone, &sizeSpec, &sizeInit, &sizeBuffer);

    /// allocate memory for required buffers
    pMemSpec = (Ipp8u*) ippMalloc(sizeSpec);

    if (sizeInit > 0)
    {
        pMemInit = (Ipp8u*) ippMalloc(sizeInit);
    }

    if (sizeBuffer > 0)
    {
        pMemBuffer = (Ipp8u*) ippMalloc(sizeBuffer);
    }

    /// initialize FFT specification structure
    ippsFFTInit_C_32fc(&pSpec, FFTOrder, flag, ippAlgHintNone, pMemSpec, pMemInit);

    /// free initialization buffer
    if (sizeInit > 0)
    {
        ippFree(pMemInit);
    }

    /// perform forward FFT
    ippsFFTFwd_CToC_32fc(Src, Dst, pSpec, pMemBuffer);

    /// ...

    /// free buffers
    if (sizeBuffer > 0)
    {
        ippFree(pMemBuffer);
    }

    ippFree(pMemSpec);
}

Result:

Dst ->      {  96.0, 128.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 },
           {   0.0,   0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 },
            { -64.0,   0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 },
            {   0.0,   0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 },
            { -32.0, -32.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 },
            {   0.0,   0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 },
            {   0.0, -64.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 },
            {   0.0,   0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }

See Also