Pregunta

I'm currently working with the FFTW2 (Fastest Fourier Transform in the West) library, and after writing a successful routine in Fortran, I am moving on to C. However, I'm having some trouble with data assigning when I try to input the data to transform (ie, the values of sin(x)). Currently, my code is:

#include <stdio.h>
#include <fftw.h>
#include <math.h>
#include <complex.h>

void compute_fft(){
  int i;
  const int n[8];
  fftw_complex in[8];
  fftwnd_plan p;

  in[0]->re = 0;
  in[1]->re = (sqrt(2)/2);
  in[2]->re = 1;
  in[3]->re = (sqrt(2)/2);
  in[4]->re = 0;
  in[5]->re = -(sqrt(2)/2);
  in[6]->re = -1;
  in[7]->re = -(sqrt(2)/2);

  for(i = 0; i < 8; i++){
    (in[i])->im = 0;
  }

  p = fftwnd_create_plan(8, n, FFTW_FORWARD, FFTW_ESIMATE | FFTW_IN_PLACE);
  fftwnd_one(p, &in[0], NULL);
  fftwnd_destroy_plan(p);

  printf("Sin\n");
  for(i = 0; i < 8; i++){
    printf("%d\n", n[i]);
  }
}

I've been using this http://fftw.org/fftw2_doc/ link for documentation/tutorial purposes, and currently my error is "invalid type argument of a->a (have afftw_complexa)", and the 'a' characters on either side of the -> and fftw_complex have carats above them. I'm using basically the same pattern that worked when I wrote this in Fortran, and I seem to be following the tutorial, it's really just this assignment here that I am messing up the syntax on. For the record, the compiler I am using is nvcc, if it makes a difference (I previously tried gcc). If anyone here has every used FFTW2 in C before, could you help correct my mistake? Thank you!

No hay solución correcta

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top