2.1.22.2.1.32 fft_fft_real


Description

calculates the discrete Fourier transform or inverse Fourier transform of a sequence of iSize real data values. For forward FT, the output is in Hermitian form; For backward FT, the input sequence is in Hermitian form.

Syntax

int fft_fft_real( int iSize, double * vSig, FFT_SIGN iSign = FFT_FORWARD )

Parameters

iSize
[input] the number of data values in the sequence.
vSig
[Modify] Input data array for transformation, also used for output the discrete Fourier transform stored in Hermitian form.
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 4 columns. The first column contains 7 data. This piece
//of code reads in a sequence of real data values from the first column, and prints
//their discrete Fourier transform (as computed by fft_fft_real) into the second and
//the third column, after    expanding it from Hermitian form into a full complex sequence.
//It also performs an inverse    transform to obtain the original data in the fourth column.

#include <..\originlab\fft.h>    
void TEST_fft_fft_real()
{
    int n = 7, j, success, n2, nj;
    //Attach 4 Datasets to these 4 columns
    Worksheet wks = Project.ActiveLayer();
    if(wks)
    {
        Dataset xx(wks, 0);
        Dataset aa(wks, 1);
        aa.SetSize(n);
        Dataset bb(wks, 2);
        bb.SetSize(n);
        Dataset cc(wks, 3);
        cc.SetSize(n);
        
        vector x = xx;
    
        ///FT
        success = fft_fft_real(n, x);
        
        //output the result into worksheet.
        if(success == 0)
        {
            aa[0] = x[0];
            bb[0] = 0.0;
            n2 = (n-1)/2;
            for (j = 1; j<=n2; j++)
            {
                nj = n - j;
                aa[j] = x[j];
                aa[nj] = x[j];
                bb[j] = x[nj];
                bb[nj] = -x[nj];
            }
            if (n % 2==0)
            {
                aa[n2+1] = x[n2+1];
                bb[n2+1] = 0.0;
            }
        }
        
        ///IFT
        success = fft_fft_real(n, x, FFT_BACKWARD);
        
        //output the result into worksheet.
        cc = x;
    }
}

Remark

See Also

fft_fft_complex, fft_fft_2d_complex

Header to Include

fft.h

Reference