#include<math.h>
#include "dft.h"

void dft(DTYPE real_sample[SIZE], DTYPE imag_sample[SIZE])
{
  int i, j;
  DTYPE w;
  DTYPE c,s;

  DTYPE temp_real[SIZE];
  DTYPE temp_imag[SIZE];

  for(i=0; i<SIZE; i+=1)
  {
    temp_real[i] = 0;
    temp_imag[i] = 0;
    w =  2.0 * 3.141592653589 * (DTYPE)i / (DTYPE)SIZE;
    for(j=0; j<SIZE; j+=1)
    {
      c = cos(j * w);
      s = sin(j * w);
      temp_real[i] += (real_sample[j] * c - imag_sample[j] * s);
      temp_imag[i] += (real_sample[j] * s + imag_sample[j] * c);
    }
  }

  for (i=0; i<SIZE; i+=1)
  {
    real_sample[i] = temp_real[i];
    imag_sample[i] = temp_imag[i];
  }


}
