X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/d1e05f17aa7a1169e3e8ea4ccef8817d7dffb0da..cc8ed2bd6bd5a60156d63040b2d352ad5b1a3095:/examples/2d_fft/fft2d.dsp diff --git a/examples/2d_fft/fft2d.dsp b/examples/2d_fft/fft2d.dsp new file mode 100644 index 0000000..c77a660 --- /dev/null +++ b/examples/2d_fft/fft2d.dsp @@ -0,0 +1,51 @@ +import ( "../../architecture/fft.lib" ) ; +import ( "../../architecture/complex.lib" ) ; + +GREY_MAX = 256; + +//fft2d(x,y) = vectorize(x) : vectorize(y) <: picks(n) : real2complex(n) : fft(n) : stops(n/2), pcplx_moduls(n/2) : modules_vector(n/2); +//fft2d(x,y) = vectorize(x) : vectorize(y) : fft(x) : fftc(y) : pcplx_moduls(y) : modules_vector(y); +//fft2d(x,y) = vectorize(x) : fft(x) : fftc(y) : pcplx_moduls(y) : modules_vector(y); + +matricize(x, y) = vectorize(y) : vectorize(x); + +ffts(n, m) = par(i, n, (fft(m) : nconcat(m))); + +fftcs(n, m) = par(i, n, (fftc(m) : nconcat(m))); + +lines_fft(n, m) = _ <: picks(n) : ffts(n, m) : nconcat(n); + +lines_fftc(n, m) = _ <: picks(n) : fftcs(n, m) : nconcat(n); + +take_column(n, m) = par(i, n, [m]) : nconcat(n); + +matrix_transpose(n, m) = _ <: picks(n) <: par(i, m, take_column(n, i)) : nconcat(m); + +matrix_pcplx2modul(n, m) = _ <: picks(n) : par(i, n, ( _ <: picks(m) : pcplx_moduls(m) : nconcat(m))) : nconcat(n); + +matrix_real2pcplx(n, m) = _ <: picks(n) : par(i, n, ( _ <: picks(m) : real2pcplx(m) : nconcat(m))) : nconcat(n); + +//normalize(n) = _ , n : /; +normalize(n, m) = _, (m : vectorize(n)) : /; + +unnormalize(n) = par(i, n, ( _ , GREY_MAX : *)); + +norm_out(n, m) = _ <: picks(n) : par(i, n, ( _ <: picks(m) : unnormalize(m) : nconcat(m))) : nconcat(n) : serialize; + +output(n, m) = serialize; + +//fft2d(x, y) = matricize(x, y) : lines_fft(x, y) : matrix_transpose(x, y) : lines_fftc(y, x) : matrix_transpose(y, x) : output(x, y); +//fft2d(x, y) = normalize(GREY_MAX) : matricize(x, y) : lines_fft(x, y) : matrix_transpose(x, y) : lines_fftc(y, x) : matrix_transpose(y, x) : norm_out(x, y); +//fft2d(x, y) = matricize(x, y) : matrix_real2pcplx(x, y) : matrix_pcplx2modul(x, y) : output(x, y); +//fft2d(x, y) = matricize(x, y) : output(x, y); +fft2d(x, y) = normalize(GREY_MAX) : matricize(x, y) : lines_fft(x, y) : matrix_transpose(x, y) : lines_fftc(y, x) : matrix_transpose(y, x) : norm_out(x, y); + +new_fft2d(x, y) = normalize(y, GREY_MAX) : vectorize(x) : lines_fft(x, y) : matrix_transpose(x, y) : lines_fftc(y, x) : matrix_transpose(y, x) : norm_out(x, y); + +//safer with x=y because tests and zero padding are still to implement +//process = fft2d(32,32); + +process = new_fft2d(32,32); + + +