File: fft_test.m

package info (click to toggle)
nfft 3.5.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,972 kB
  • sloc: ansic: 44,442; lisp: 1,697; makefile: 1,322; sh: 744; sed: 5
file content (137 lines) | stat: -rw-r--r-- 3,919 bytes parent folder | download
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
% Copyright (c) 2002, 2017 Jens Keiner, Stefan Kunis, Daniel Potts
%
% This program is free software; you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free Software
% Foundation; either version 2 of the License, or (at your option) any later
% version.
%
% This program is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
% FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
% details.
%
% You should have received a copy of the GNU General Public License along with
% this program; if not, write to the Free Software Foundation, Inc., 51
% Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
N=64;
T=3*N; %T=5*N/2;
R=3*N/2;


f=fft2(phantom(N));
%f=imresize(im2double(imread('trui.png')),N/256);
fr=real(f); fi=imag(f);
save 'input_data_r.dat' fr -ascii -double
save 'input_data_i.dat' fi -ascii -double


if ispc
    cmd='polar_fft_test.exe';
else 
    cmd='./polar_fft_test';
end
system(sprintf('%s %d %d %d',cmd,N,T,R));

polar_fft_error = load('polar_fft_error.dat');
polar_ifft_error3 = load('polar_ifft_error3.dat');
polar_ifft_error6 = load('polar_ifft_error6.dat');
polar_ifft_error9 = load('polar_ifft_error9.dat');

figure(1);
h=semilogy(1:length(polar_fft_error),polar_fft_error);
set(h,'LineWidth',2.0); set(h,'Markersize',10);
set(gca,'FontSize',22);
grid;
axis([0,10,10^-15,1]);
title('Test of the polar FFT');
xlabel('m');
ylabel('E_{max}');
print fig_polar_fft -deps2

figure(2);
it=0:10:100;
h=plot(it,polar_ifft_error3,'-',it,polar_ifft_error6,'--',it,polar_ifft_error9,'-.');
set(h,'LineWidth',2.0); set(h,'Markersize',10);
set(gca,'FontSize',22);
grid;
title('Test of the inverse polar FFT');
xlabel('iterations');
ylabel('E_{max}');
legend('m=3','m=6','m=9');
print fig_ipolar_fft -deps2

disp(sprintf('\n'));


if ispc
    cmd_mpolar_fft_test='mpolar_fft_test.exe';
else 
    cmd_mpolar_fft_test='./mpolar_fft_test';
end
system(sprintf('%s %d %d %d',cmd_mpolar_fft_test,N,T,R));

mpolar_fft_error = load('mpolar_fft_error.dat');
mpolar_ifft_error3 = load('mpolar_ifft_error3.dat');
mpolar_ifft_error6 = load('mpolar_ifft_error6.dat');
mpolar_ifft_error9 = load('mpolar_ifft_error9.dat');

figure(3);
h=semilogy(1:length(mpolar_fft_error),mpolar_fft_error);
set(h,'LineWidth',2.0); set(h,'Markersize',10);
set(gca,'FontSize',22);
grid;
axis([0,10,10^-15,1]);
title('Test of the mpolar FFT');
xlabel('m');
ylabel('E_{max}');
print fig_mpolar_fft -deps2

figure(4);
it=0:2:20;
h=semilogy(it,mpolar_ifft_error3,'-',it,mpolar_ifft_error6,'--',it,mpolar_ifft_error9,'-.');
set(h,'LineWidth',2.0); set(h,'Markersize',10);
set(gca,'FontSize',22);
grid;
title('Test of the inverse mpolar FFT');
xlabel('iterations');
ylabel('E_{max}');
legend('m=3','m=6','m=9');
print fig_impolar_fft -deps2

disp(sprintf('\n'));


if ispc
    cmd_linogram_fft_test='linogram_fft_test.exe';
else 
    cmd_linogram_fft_test='./linogram_fft_test';
end
system(sprintf('%s %d %d %d',cmd_linogram_fft_test,N,T,R));

linogram_fft_error = load('linogram_fft_error.dat');
linogram_ifft_error3 = load('linogram_ifft_error3.dat');
linogram_ifft_error6 = load('linogram_ifft_error6.dat');
linogram_ifft_error9 = load('linogram_ifft_error9.dat');

figure(5);
h=semilogy(1:length(linogram_fft_error),linogram_fft_error);
set(h,'LineWidth',2.0); set(h,'Markersize',10);
set(gca,'FontSize',22);
grid;
axis([0,10,10^-15,1]);
title('Test of the linogram FFT');
xlabel('m');
ylabel('E_{max}');
print fig_lino_fft -deps2

figure(6);
it=0:2:20;
h=semilogy(it,linogram_ifft_error3,'-',it,linogram_ifft_error6,'--',it,linogram_ifft_error9,'-.');
set(h,'LineWidth',2.0); set(h,'Markersize',10);
set(gca,'FontSize',22);
grid;
title('Test of the inverse linogram FFT');
xlabel('iterations');
ylabel('E_{max}');
legend('m=3','m=6','m=9');
print fig_ilino_fft -deps2