[問題] 要如何正確的FFTW使用

看板C_and_CPP (C/C++)作者 (aada)時間16年前 (2010/03/05 14:17), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
請問一下我目前在測試FFTW, 1025*1025的矩陣, 執行100次的二維FFT與IFFT, 感覺整體的運算速度不快約45秒, 是不是我的程式上少了些什麼, 以及所謂快是指什麼意思呢(FFTW號稱世界最快的FFT)? 謝謝 以下是我的程式碼 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <time.h> #include "fftw3.h" #define NNx 1025 #define NNy 1025 // ================= Main ================= // int main(int argc, char *argv[]) { fftw_complex *in, *out, *in2; fftw_plan p,q; clock_t start, end; int i=0, j=0, k=0; in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) *NNx*NNy ); in2 = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) *NNx*NNy ); out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) *NNx*NNy ); for( i=0; i < NNx*NNy; i++) { in[i][0] = i; in[i][1] = 0.0; } start=clock(); for( k=0; k<100; k++) { p=fftw_plan_dft_2d( NNx, NNy, in, out, FFTW_FORWARD, FFTW_ESTIMATE); q=fftw_plan_dft_2d( NNx, NNy, out, in2, FFTW_BACKWARD, FFTW_ESTIMATE); fftw_execute( p ); // repeat as needed// fftw_execute( q ); } end=clock(); printf(" FFTW : %f second\n", (double) (end-start)/CLOCKS_PER_SEC ); fftw_destroy_plan(p); fftw_destroy_plan(q); fftw_free(in); fftw_free(out); system("PAUSE"); return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.122.192.147
文章代碼(AID): #1BaA8NT4 (C_and_CPP)
文章代碼(AID): #1BaA8NT4 (C_and_CPP)