0

私は単純な FFTW ルーチン (バージョン 2) を作成しようとしています。ほぼ骨が折れたと思いますが、fftwnd_one 関数を呼び出すと永続的なセグメンテーション違反が発生します (私は 1 つを実行しています)。次元変換ですが、モジュール性のために n 次元コードを使用しています)。しかし、私の問題は計画の作成にあると思います。このコードの何が問題なのか、誰か洞察を提供できますか? もしそうなら、私はそれを大いに感謝します - ありがとう!

参考までに、ここで使用している関数は sin(x) です。すべての数学演算が実装されているわけではないことに気付きました。最初に FFTW2 ライブラリを機能させようとしているだけです。

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

int main(){
  int i;
  fftw_complex in[8];
  fftwnd_plan p;
  const int *n;
  int temp = (int)pow(2, 2)*pow(3,2)*pow(5,1)*pow(7,1)*pow(11,1)*pow(13,0);
  n = &temp;

  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]);
  }
  return 0;
}
4

2 に答える 2

1

最初の 2 つのパラメーターはfftwnd_create_plan完全に間違っているように見えます。サイズ 8 の 1D FFT の計画を作成したいだけのようです (1D FFT だけが必要な場合に、なぜ fftwnd_create_plan を使用しているのかという疑問が生じます)。呼び出しは次のようになります。

const int n = 8;
p = fftwnd_create_plan(1,   // rank = 1, i.e. 1D
                       &n,  // size of first (and only) dimension = n = 8
                       FFTW_FORWARD,
                       FFTW_ESIMATE | FFTW_IN_PLACE);
于 2011-05-17T06:41:20.810 に答える
0

You seem to be treating n as an array, when it only points to a single integer. For example, should not this:

printf("%d\n", n[i]);

be:

printf("%d\n", in[i]);
于 2011-05-17T06:06:48.890 に答える