# 2.1.22.2.1.25 fft_fft_complex

## Description

calculates the discrete Fourier transform or inverse Fourier transform of a sequence of iSize complex data values.

## Syntax

int fft_fft_complex( int iSize, double * vSigReal, double * vSigImag, FFT_SIGN iSign = FFT_FORWARD )

## Parameters

iSize
[input] the number of data values.
vSigReal
[modify] the real part of the data for input, and the real part of the transformed data for output
vSigImag
[modify] the imaginary part of the data for input, and the imaginary part of the transformed data for output
iSign
[input] the transformation to carry out
= FFT_FORWARD: FFT (by default)
= FFT_BACKWARD: IFFT.

## Return

Returns 0 for success or error codes for failure.

## Examples

EX1

//Assume the current Worksheet has 6 columns, the first two columns contain 7 data each.
//The first column is the real part of the original complex data and the second column
//is the imaginary part. This piece of code reads in a sequence of these 7 complex data
//values and put the result of the discrete Fourier transform of the original data
//into the third and fourth columns. The third column is the real part and the fourth
//column is the imaginary part. Then inverse Fourier transform is performed, and the
//result is output into the fifth and sixth column.

#include <..\originlab\fft.h>
void TEST_fft_fft_complex()
{
int nSize = 7, success;
//Attach two Datasets to these 2 columns

Worksheet wks = Project.ActiveLayer();
if(wks)
{
Dataset xx(wks, 0);
Dataset yy(wks, 1);
Dataset aa(wks, 2);
aa.SetSize(nSize);
Dataset bb(wks, 3);
bb.SetSize(nSize);
Dataset cc(wks, 4);
cc.SetSize(nSize);
Dataset dd(wks, 5);
dd.SetSize(nSize);

//Because Dataset cannot be the parameter of function, but vector can.
vector x = xx, y = yy;

///FT
success = fft_fft_complex(nSize, x, y);
//put the result back to the current worksheet, the third and the fourth column.
aa = x;
bb = y;

///IFT
success = fft_fft_complex(nSize, x, y, FFT_BACKWARD);
//put the result back to the current worksheet, the fifth and the sixth column.
cc = x;
dd = y;
}
}