%% flopscount
%% calculates the floating point operationa to compute Fourier coefficients in two ways

N = 101;
y = rand(N,1);
A = cossinmat(N);

%% diagonal piece
if rem(N,2) == 0 
   d = [N;(N/2)*ones(N-2,1);N];
else
   d = [N;(N/2)*ones(N-1,1)];
end
   
   
% bone head method   Gaussian elimination
flops(0)

x1 = A\y;

FL1 = flops

% method of dot-products
flops(0)

z = A'*y;
x2 = z./d;

FL2 = flops;

% comparison

speedupfactor = FL2/FL1

error = sqrt((x1-x2)'*(x1-x2))
% squared length









   
