/*******************************************************************************
* Copyright 2015-2018 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.
*******************************************************************************/
// The code example below illustrates how to use the function ippsMulPack_32f_I.
// implemented with Intel(R) Integrated Primitives (Intel(R) IPP) functions:
// ippsFFTGetSize_R_32f
// ippsFFTInit_R_32f
// ippsSet_32f
// ippsFFTFwd_RToPack_32f
// ippsMulPack_32f_I
// ippsFFTInv_PackToR_32f
#include <stdio.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 = 0;
IppStatus status = ippStsNoErr;
Ipp32f pFlt[8] = {1.0f/3,1.0f/3,1.0f/3,0,0,0,0,0}; /* Pointers to filter signal */
Ipp32f pSrc[8], pDst[8]; /* Pointers to source/filter/destination signals */
Ipp32f pSrcFr[8], pFltFr[8]; /* Pointers to source/filter/destination signals into the frequency domain */
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) )
ippsSet_32f( 3, pSrc, 8 );
pSrc[3] = 5;
/* forward FFT transform : the source signal is transformed into the frequency domain*/
check_sts( status = ippsFFTFwd_RToPack_32f( pSrc, pSrcFr, pSpec, NULL ) )
/* forward FFT transform: the filter signal is transformed into the frequency domain */
check_sts( status = ippsFFTFwd_RToPack_32f( pFlt, pFltFr, pSpec, NULL ) )
/* multiplying the packed data */
check_sts( status = ippsMulPack_32f_I( pFltFr, pSrcFr, 8 ) )
/* inverse FFT transform : the filtered data is transformed to the time domain */
check_sts( status = ippsFFTInv_PackToR_32f( pSrcFr, pDst, pSpec, NULL ) )
printf("filtered =");
for (i = 0; i < 8; ++i) printf(" %f", pDst[i]);
printf("\n");
EXIT_MAIN
ippFree( pMemInit );
ippFree( pSpec );
ippFree( pBuffer );
printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
return status;
}