% CS 4220 (Spring 2010) Assignment 1
% Test Script P3.

clc
% Generate W_10 explictly...
W = [1];
for k=1:10
    W = [W W;W -W]/2;
end
% Verify FastProd via a random example...
X = randn(1024,50);
Y0 = W*X;
Y = FastProd(X);
fprintf('error = %10.3e\n\n',norm(Y-Y0,1))

% Now examine how work increases with n...
nRepeat = 1;                % May have to increase for benchmark reliability
disp('       n     Time')
disp('     -------------')
for k=10:18
    n = 2^k;
    x = randn(n,1);
    tic
    for j=1:nRepeat
       y = FastProd(x);
    end
    t = toc/nRepeat;
    fprintf('%10d   %5.3f\n',n,t)
end
