% NxM is the size of the FFT to test. Note 65536 was chosen as a test % for thrashing of the cache when copying from FFTW's packed format to % a normal matrix. N = [512, 513, 514, 512, 65536]; M = [512, 513, 512, 514, 1]; rep = 10; savedata = 0; testcmplx = 0; infft = cell(1,length(N)); resfft = cell(1, length(N)); resfft2 = cell(1, length(N)); timfft = cell(1,length(N)); timfft2 = cell(1,length(N)); if (exist('OCTAVE_VERSION')) platfrm = ['Octave ' version]; else platfrm = ['Matlab ' version]; end if (testcmplx) fprintf('Testing %s for complex ffts\n\n', platfrm); else fprintf('Testing %s for real ffts\n\n', platfrm); end for i=1:length(N) if (testcmplx) a = randn(N(i),M(i)) + 1i * randn(N(i),M(i)); else a = randn(N(i),M(i)); end infft{i} = a; fprintf('Testing fft(%5d,%5d) ', N(i), M(i)); if (exist('OCTAVE_VERSION')) eval('fflush(stdout);'); end % Call fft twice to ensure all variables initialized b = fft(a); b = fft(a); timfft{i} = 0; for j=1:rep t = cputime; b = fft(a); timfft{i} = timfft{i} + cputime - t; end resfft{i} = b; timfft{i} = timfft{i} / rep; fprintf('%5.2e sec\n', timfft{i}); fprintf('Testing fft2(%5d,%5d) ', N(i), M(i)); if (exist('OCTAVE_VERSION')) eval('fflush(stdout);'); end % Call fft2 twice to ensure all variables initialized b = fft2(a); b = fft2(a); timfft2{i} = 0; for j=1:rep t = cputime; b = fft2(a); timfft2{i} = timfft2{i} + cputime - t; end resfft2{i} = b; timfft2{i} = timfft2{i} / rep; fprintf('%5.2e sec\n', timfft2{i}); end fprintf('Saving Data '); if (exist('OCTAVE_VERSION')) eval('fflush(stdout);'); end if (savedata) save testfft.mat infft resfft timfft resfft2 timfft2 N M testcmplx platfrm else save testfft.mat timfft timfft2 N M testcmplx platfrm end fprintf('done\n');