next up previous
Next: Multi-Dimensional Forward Transform of Up: Sample Codes for Using Previous: Sample Codes for Using

One-Dimensional Forward Transform of Complex Data

This code generates an array with the values $f(x) = e^{-2 \pi i
D x/N}$. The resultant transform has value $F_D=N$ and all the other values equal to zero.

#define N 16 // Number of complex points in the data
#define D 5
void main()
{
  int a;
  float f[2*N]; // An array twice as large as the number of complex points
  float pi=2.*asin(1.),x=2.*pi*D/(float)N;

  for(a=0;a<N;a++)
  {
    f[2*a]=cos(x*(float)a); // f(i) = e^(-2 pi i D a/N)
    f[2*a+1]=-sin(x*(float)a);
  }

  fftc1(f,N,1,1);

  for(a=0;a<N;a++)
    printf("%d %f %f\n",a,f[2*a],f[2*a+1]);
}

OUTPUT:

0 0.000000 0.000001
1 0.000001 0.000001
2 0.000001 0.000001
3 0.000001 0.000001
4 0.000003 0.000001
5 15.999999 -0.000008
6 -0.000003 0.000001
7 -0.000001 0.000001
8 -0.000001 0.000001
9 -0.000001 0.000001
10 -0.000000 0.000001
11 -0.000000 0.000001
12 -0.000000 0.000001
13 0.000001 -0.000001
14 0.000000 0.000001
15 0.000000 0.000001



Go to The FFTEASY Home Page
Go to Gary Felder's Home Page
Send email to Gary at gfelder@email.smith.edu

This documentation was generated on 2003-09-30