-
Notifications
You must be signed in to change notification settings - Fork 0
/
fft_speed-up.i
63 lines (45 loc) · 1.05 KB
/
fft_speed-up.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
func precompute_fft_speed {
N = 2740 ;
speed = array(float,N) ;
write, "Analysing fft speed ..." ;
for (i=1 ; i<= N ; i++) {
write, i, "/", N ;
im = array(float,i,i) ;
tic ;
fim = fft(im, 1) ;
speed(i) = tac() ;
write, "speed=", speed(i) ;
}
cfitsWrite, "init/fft_speed.fits.gz", speed ;
}
func fft_best_size(N) {
fft_speed = cfitsRead("~/yorick/init/fft_speed.fits.gz") ;
N_extra = 30 ;
speed = array(float,N_extra) ;
for (i=1 ; i<= N_extra ; i++) {
speed(i) = fft_speed(N+2*(i-1)) ;
}
ou = speed(mnx) ;
return N+2*(ou-1) ;
}
// TEST
/*
n = 1301 ;
im = array(float,n,n) ;
im(*) = 1 ;
im = gauss_kernel(n, n/100.) ;
n2 = fft_best_size(n) ;
write, n, n2 ;
tic
n2 = 1323 ;
im2 = array(float,n2,n2) ; n_extra = (n2 -n)/2 ;
im2(n_extra+1:-n_extra,n_extra+1:-n_extra) = im ;
tac()
tic ; fim = fft(im, 1) ; tac() ;
tic ; fim2= fft(im2, 1) ; tac() ;
window, 10 ; plim, im2 ;
window, 11 ; fma ;
plg, abs(fim(,1)), span(0,1,n) ;
plg, abs(fim2(,1)), span(0,1,n2), color="red" ;
limits, 0, 0.05 ;
*/