Intel® Integrated Performance Primitives Developer Guide and Reference

ID 790148
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

FFTFwd_RToPack, FFTFwd_RToPerm, FFTFwd_RToCCS

Computes the forward or inverse fast Fourier transform (FFT) of a real signal.

Syntax

Case 1: Not-in-place operation, result in Pack Format

IppStatus ippsFFTFwd_RToPack_32f(const Ipp32f* pSrc, Ipp32f* pDst, const IppsFFTSpec_R_32f* pFFTSpec, Ipp8u* pBuffer);

IppStatus ippsFFTFwd_RToPack_64f(const Ipp64f* pSrc, Ipp64f* pDst, const IppsFFTSpec_R_64f* pFFTSpec, Ipp8u* pBuffer);

Case 2: In-place operation, result in Pack Format.

IppStatus ippsFFTFwd_RToPack_32f_I(Ipp32f* pSrcDst, const IppsFFTSpec_R_32f* pFFTSpec, Ipp8u* pBuffer);

IppStatus ippsFFTFwd_RToPack_64f_I(Ipp64f* pSrcDst, const IppsFFTSpec_R_64f* pFFTSpec, Ipp8u* pBuffer);

Case 3: Not-in-place operation, result in Perm Format

IppStatus ippsFFTFwd_RToPerm_32f(const Ipp32f* pSrc, Ipp32f* pDst, const IppsFFTSpec_R_32f* pFFTSpec, Ipp8u* pBuffer);

IppStatus ippsFFTFwd_RToPerm_64f(const Ipp64f* pSrc, Ipp64f* pDst, const IppsFFTSpec_R_64f* pFFTSpec, Ipp8u* pBuffer);

Case 4: In-place operation, result in Perm Format.

IppStatus ippsFFTFwd_RToPerm_32f_I(Ipp32f* pSrcDst, const IppsFFTSpec_R_32f* pFFTSpec, Ipp8u* pBuffer);

IppStatus ippsFFTFwd_RToPerm_64f_I(Ipp64f* pSrcDst, const IppsFFTSpec_R_64f* pFFTSpec, Ipp8u* pBuffer);

Case 5: Not-in-place operation, result in CCS Format

IppStatus ippsFFTFwd_RToCCS_32f(const Ipp32f* pSrc, Ipp32f* pDst, const IppsFFTSpec_R_32f* pFFTSpec, Ipp8u* pBuffer);

IppStatus ippsFFTFwd_RToCCS_64f(const Ipp64f* pSrc, Ipp64f* pDst, const IppsFFTSpec_R_64f* pFFTSpec, Ipp8u* pBuffer);

Case 6: In-place operation, result in CCS Format.

IppStatus ippsFFTFwd_RToCCS_64f_I(Ipp64f* pSrcDst, const IppsFFTSpec_R_64f* pFFTSpec, Ipp8u* pBuffer);

IppStatus ippsFFTFwd_RToCCS_32f_I(Ipp32f* pSrcDst, const IppsFFTSpec_R_32f* 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.

pDst

Pointer to the output array containing packed complex values.

pSrcDst

Pointer to the input and output arrays for the in-place operation.

pBuffer

Pointer to the external work buffer.

Description

These functions compute the forward FFT of a real signal and store the result in Pack, Perm, or CCS packed formats respectively. The transform is performed in accordance with the pFFTSpec specification parameters: the transform order, the normalization flag, and the specific code hint. Before calling these functions the FFT specification structure must be initialized by the corresponding flavors of ippsFFTInit_R. The length of the FFT must be a power of 2.

Use these functions with the external work buffer pBuffer. Once the work buffer is allocated, it can be used for all following calls to 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 ippsFFTGetSize_R function.

ippsFFTFwd_RToPack. This function computes the forward FFT and stores the result in Pack format.

ippsFFTFwd_RToPerm. This function computes the forward FFT and stores the result in Perm format.

ippsFFTFwd_RToCCS. This function computes the forward FFT and stores the result in CCS format.

Tables "Arrangement of Forward Fourier Transform Results in Packed Formats - Even Length" and "Forward Fourier transform Result Representation in Packed Formats - Odd Length" show how the output results are arranged in the packed formats.

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

/*******************************************************************************
* 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.
*******************************************************************************/

//   A simple example of performing the forward FFT for processing real data
//     for CCS packed formats and computing magnitude
// implemented with Intel(R) Integrated Primitives (Intel(R) IPP) functions:
//     ippiFFTGetSize_R_32f
//     ippiFFTInit_R_32f
//     ippiFFTFwd_RToPack_32f_C1R
//     ippsMagnitude_32fc


#include <stdio.h>
#include <math.h>
#include "ipp.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) 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(void)
{
    int i;
    IppStatus status = ippStsNoErr;
    Ipp32f pSrc[8], pDst[10];         /* Pointers to source/destination images */
    Ipp32f pMagn[4];                  /* Pointer to the computed magnitude values */
    IppsFFTSpec_R_32f* pSpec = NULL;  /* Pointer to FFT pSpec structure */

    Ipp8u *pMemInit = NULL, *pBuffer = NULL, *pSpecMem = NULL; /* Pointer to the work buffers */
    int sizeSpec = 0, sizeInit = 0, sizeBuf = 0;               /* size of FFT pSpec structure, Init and work buffers */

    check_sts( status = ippsFFTGetSize_R_32f(3, IPP_FFT_DIV_INV_BY_N, ippAlgHintNone, &sizeSpec, &sizeInit, &sizeBuf) )

    /* memory allocation */
    pSpecMem = (Ipp8u*) ippMalloc( sizeSpec );
    pBuffer  = (Ipp8u*) ippMalloc( sizeBuf );
    pMemInit = (Ipp8u*) ippMalloc( sizeInit );

    check_sts( status = ippsFFTInit_R_32f(&pSpec, 3, IPP_FFT_DIV_INV_BY_N, ippAlgHintNone, pSpecMem, pMemInit) )

    for (i = 0; i< 8 ; ++i)
    {
        pSrc[i] = (float)cos(IPP_2PI * i * 16.0/64);
    }

    check_sts( status = ippsFFTFwd_RToCCS_32f( pSrc, pDst, pSpec, pBuffer ) )

    check_sts( status = ippsMagnitude_32fc( (Ipp32fc*)pDst, pMagn, 4 ) )

    printf("FFT Magnitude =  %f  %f  %f  %f\n", pMagn[0], pMagn[1], pMagn[2], pMagn[3]);

EXIT_MAIN
    ippFree( pMemInit );
    ippFree( pSpec );
    ippFree( pBuffer );
    printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
    return (int)status;
}