c++ - Different results from FFTW with FFTW_ESTIMATE and FFTW_MEASURE -


i'm using fftw perform ffts on 2d image data. 1 can use either fftw_estimate or fftw_measure plan fft. assuming same results when using either one. found case huge differences.

code (minimum example):

template<class t_img> void aa(t_img& img) {     float* in = new float[2048*2048];     float* in2 = new float[2048*2048];     float* out = new float[2048*2048*2];     float* out2 = new float[2048*2048*2];     int dim[2] = {2048,2048};      fftwf_plan plan1 = fftwf_plan_dft_r2c(2, dim, in, reinterpret_cast<fftwf_complex*>(out), fftw_estimate);     fftwf_plan plan2 = fftwf_plan_dft_r2c(2, dim, in2, reinterpret_cast<fftwf_complex*>(out2), fftw_measure);     img.load();     for(int y=0; y<2048; y++)         for(int x=0; x<2048; x++){             in2[y*2048 + x] = img(x, y);//(std::abs(1024-x) < 20 && std::abs(1024-y) < 20) ? 1e9 : 0;             in[y*2048 + x] = img(x, y); //(std::abs(1024-x) < 20 && std::abs(1024-y) < 20) ? 1e9 : 0;         }     fftwf_execute(plan2);     fftwf_execute(plan1);     for(int y=0; y<2048; y++)         for(int x=0; x<1025; x++){             float r1 = out[(y*1025 + x)*2];             float r2 = out2[(y*1025 + x)*2];             float c1 = out[(y*1025 + x)*2+1];             float c2 = out2[(y*1025 + x)*2+1];             float diffr = std::abs(r1-r2);             float diffc = std::abs(c1-c2);             if((diffr > 1 && diffr/std::abs(r1) > 1) || (diffc > 1 && diffc/std::abs(c1)) > 1){                 std::cerr << "err " << diffr << "; " << diffc << std::endl;                 return;             }         } } 

i have image float values ranging 0 ~3e9. kind of sinc function in middle. error gets triggered example (18, 229) vs (200, 466) on point (42, 91).

how possible, values far off? how can solve that?

additionally tried same in double precision. worked... cannot afford overhead of double precision calculations , expected reasonable values single precision.

values @ point in dp (-580, -166)


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -