FFTW
をテンプレートにして作成
[
トップ
|
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
*[[FFTW:http://www.fftw.org/]] [#t3f818a1]
----
#contents
----
#include(build_fftw,notitle)
fftw_plan fftw_plan_dft_r2c_2d(int n0, int n1, double *i...
fftw_plan fftw_plan_dft_r2c_3d(int n0, int n1, int n2, d...
fftw_plan fftw_plan_dft_r2c(int rank, const int *n, doub...
#code(c){{
for(int i = 0; i < w; ++i){
for(int j = 0; j < h; ++j){
double re, im;
if(j >= h/2+1){
int j0 = h-j-1;
re = out[j0+i*h1][0];
im = -out[j0+i*h1][1];
}
else{
re = out[j+i*h1][0];
im = out[j+i*h1][1];
}
}
}
}}
#code(C){{
void FFTW_c2r(Array2 &reImg, Array2 &imImg, int w, int h)
{
fftw_complex *in;
double *out;
fftw_plan p;
in = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)*w*(...
out = (double*)fftw_malloc(sizeof(double)*w*h);
p = fftw_plan_dft_c2r_2d(w, h, in, out, FFTW_ESTIMATE);
//
for(int i = 0; i < w; ++i){
for(int j = 0; j < h/2+1; ++j){
in[j+(h/2+1)*i][0] = reImg[i][j];
in[j+(h/2+1)*i][1] = imImg[i][j];
}
}
fftw_execute(p);
for(int i = 0; i < w; ++i){
for(int j = 0; j < h; ++j){
reImg[i][j] = out[j+h*i];
imImg[i][j] = 0.0;
}
}
fftw_free(in);
fftw_free(out);
fftw_destroy_plan(p);
}
}}
**TIPS [#ladfc11f]
reImg[i][j]/(w*h);
終了行:
*[[FFTW:http://www.fftw.org/]] [#t3f818a1]
----
#contents
----
#include(build_fftw,notitle)
fftw_plan fftw_plan_dft_r2c_2d(int n0, int n1, double *i...
fftw_plan fftw_plan_dft_r2c_3d(int n0, int n1, int n2, d...
fftw_plan fftw_plan_dft_r2c(int rank, const int *n, doub...
#code(c){{
for(int i = 0; i < w; ++i){
for(int j = 0; j < h; ++j){
double re, im;
if(j >= h/2+1){
int j0 = h-j-1;
re = out[j0+i*h1][0];
im = -out[j0+i*h1][1];
}
else{
re = out[j+i*h1][0];
im = out[j+i*h1][1];
}
}
}
}}
#code(C){{
void FFTW_c2r(Array2 &reImg, Array2 &imImg, int w, int h)
{
fftw_complex *in;
double *out;
fftw_plan p;
in = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)*w*(...
out = (double*)fftw_malloc(sizeof(double)*w*h);
p = fftw_plan_dft_c2r_2d(w, h, in, out, FFTW_ESTIMATE);
//
for(int i = 0; i < w; ++i){
for(int j = 0; j < h/2+1; ++j){
in[j+(h/2+1)*i][0] = reImg[i][j];
in[j+(h/2+1)*i][1] = imImg[i][j];
}
}
fftw_execute(p);
for(int i = 0; i < w; ++i){
for(int j = 0; j < h; ++j){
reImg[i][j] = out[j+h*i];
imImg[i][j] = 0.0;
}
}
fftw_free(in);
fftw_free(out);
fftw_destroy_plan(p);
}
}}
**TIPS [#ladfc11f]
reImg[i][j]/(w*h);
ページ名: