Add /usr/local/lib/faustine and /usr/lib/faustine to preprocessor import path.
[Faustine.git] / architecture / fft2d.lib
1 import ( "fft.lib" ) ;
2 import ( "complex.lib" ) ;
3
4 GREY_MAX = 256;
5
6 //fft2d(x,y) = vectorize(x) : vectorize(y) <: picks(n) : real2complex(n) : fft(n) : stops(n/2), pcplx_moduls(n/2) : modules_vector(n/2);
7 //fft2d(x,y) = vectorize(x) : vectorize(y) : fft(x) : fftc(y) : pcplx_moduls(y) : modules_vector(y);
8 //fft2d(x,y) = vectorize(x) : fft(x) : fftc(y) : pcplx_moduls(y) : modules_vector(y);
9
10 matricize(x, y) = vectorize(y) : vectorize(x);
11
12 ffts(n, m) = par(i, n, (fft(m) : nconcat(m)));
13
14 fftcs(n, m) = par(i, n, (fftc(m) : nconcat(m)));
15
16 lines_fft(n, m) = _ <: picks(n) : ffts(n, m) : nconcat(n);
17
18 lines_fftc(n, m) = _ <: picks(n) : fftcs(n, m) : nconcat(n);
19
20 take_column(n, m) = par(i, n, [m]) : nconcat(n);
21
22 matrix_transpose(n, m) = _ <: picks(n) <: par(i, m, take_column(n, i)) : nconcat(m);
23
24 matrix_pcplx2modul(n, m) = _ <: picks(n) : par(i, n, ( _ <: picks(m) : pcplx_moduls(m) : nconcat(m))) : nconcat(n);
25
26 matrix_real2pcplx(n, m) = _ <: picks(n) : par(i, n, ( _ <: picks(m) : real2pcplx(m) : nconcat(m))) : nconcat(n);
27
28 //normalize(n) = _ , n : /;
29 normalize(n, m) = _, (m : vectorize(n)) : /;
30
31 unnormalize(n) = par(i, n, ( _ , GREY_MAX : *));
32
33 norm_out(n, m) = _ <: picks(n) : par(i, n, ( _ <: picks(m) : unnormalize(m) : nconcat(m))) : nconcat(n) : serialize;
34
35 output(n, m) = serialize;
36
37 //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);
38 //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);
39 //fft2d(x, y) = matricize(x, y) : matrix_real2pcplx(x, y) : matrix_pcplx2modul(x, y) : output(x, y);
40 //fft2d(x, y) = matricize(x, y) : output(x, y);
41 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);
42
43 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);
44
45 //safer with x=y because tests and zero padding are still to implement
46 //process = fft2d(32,32);
47
48 //process = new_fft2d(32,32);
49
50
51