% Returns the matrix whose columns are the trigonometric Fourier components
% of size 2K 
%     
%      1  cos(pi/K)   sin(pi/K)   cos(2 pi/K) sin(2 pi/K) ... cos(pi)
%      1  cos(2 pi/K) sin(2 pi/K) cos(4 pi/K) sin(4 pi/K) ... cos(pi)
%      1  cos(3 pi/K) sin(3 pi/K) cos(6 pi/K) sin(6 pi/K) ... cos(pi)
%      ...


function b = trigBasis(K)
   N=2*K;
   b=zeros(N,N);
   b(:,1) = ones(N,1);
   for j=1:K
     for i=1:N
       b(i,2*j) = cos(i*j*pi/K);
       if (2*j ~= N) b(i,2*j+1) = sin(i*j*pi/K); end
     end
   end
end
      
