Ejemplo n.º 1
0
int main (void)
{
  sfft_plan * myPlan;
  int i;
  int n = 8192;
  int k = 50;
  myPlan = sfft_make_plan (n, k, SFFT_VERSION_2, FFTW_ESTIMATE);

  /* input section */
  complex_t * input_vector = (complex_t *)sfft_malloc(n);
  printf("old: %p\n", input_vector);
  srand(17);
  srand48( time(NULL) ^ (getpid() * 171717));
  int * LARGE_FREQ = (int *) malloc (k * sizeof(*LARGE_FREQ));
  complex_t * x_f = (complex_t *) calloc (n, sizeof(*x_f));
  for (i = 0; i < k; i++) {
    LARGE_FREQ[i] = (unsigned) floor( drand48() * n);
    x_f[LARGE_FREQ[i]] = 1.0;
  }
  fftw_dft(input_vector, n, x_f, 1);
  printf("new: %p\n", input_vector);

//  sfft_output output_vector;
  complex_t * output_vector = (complex_t *) calloc (n, sizeof(complex_t));
  sfft_exec(myPlan, input_vector, output_vector);
  printf("new2: %p\n", input_vector);

//  sfft_free(input_vector);
  sfft_free_plan(myPlan);

  return 0;
}
Ejemplo n.º 2
0
extern void cpxfft(fftwf_plan plan, cpx_t *cpx, int n)
{
#ifdef TEST    
    if (plan==NULL) {
        mlock(hfftmtx); 
        fftwf_plan_with_nthreads(NFFTTHREAD); /* fft execute in multi threads */
        plan=fftwf_plan_dft_1d(n,cpx,cpx,FFTW_FORWARD,FFTW_ESTIMATE);
        fftwf_execute_dft(plan,cpx,cpx); /* fft */
        fftwf_destroy_plan(plan);
        unmlock(hfftmtx);
    } else {
        fftwf_execute_dft(plan,cpx,cpx); /* fft */
    }
#else
    sfft_plan *p;
    p=sfft_make_plan(n, 50, SFFT_VERSION_3, FFTW_ESTIMATE);
    sfft_exec(p, cpx, cpx);
#endif
}