function BenchFFT()
% O(n*log(n)) algorithms
% The discrete Fourier transform is a highly structured matrix-vector
% product. Thus, y = (DFT Matrix)*Vector would ordinarily be O(n^2)
% The fast fourier transform is a fast algorithm for doing the same
% thing in O(n*log n) flops. This script benchmarks the Matlab fft
% function.

clc
disp(' n Time for fft(n-vector) ')
disp('-------------------------------------')
nRepeat = 1000;
for t=5:20;
n = 2^t;
x = randn(n,1);
tic
for k=1:nRepeat
y = fft(x);
end
t = toc/nRepeat;
fprintf('%7d %10.8f\n',n,t)
end