% compare naive DFT and hand-coded FTT to matlab's. Barnett 11/4/11
N = 2^12;      % size 4096
f = rand(1,N);
tic; a=0*f; for i=1:N, a(i) = exp(-2i*pi*(i-1)*(0:N-1)/N) * f.';end;toc % naive
tic; b = cooleytukey(f); toc % crude hand-coded FFT
tic; c = fft(f); toc         % matlab built-in FFT
sprintf('relative error norm |b-c|/|c| = %g\n',norm(b-c)/norm(c))
sprintf('relative error norm |a-c|/|c| = %g, naive worse\n',norm(a-c)/norm(c))
