function P = CSmatrix(n)
% n is an even integer. Let m = n/2 and theta = 2*pi/n.
% P is an nxn matrix where
% P(:,1:m+1) = cos(theta*(0:n-1)'*(0:m))
% and
% P(:,m+2:n) = sin(theta*(0:n-1)'*(1:m-1))

m = n/2;
theta = 2*pi/n;
x = theta*(0:n-1)';
P = [];
for j=0:m
P = [P cos(j*x)];
end
for j=1:m-1
P = [P sin(j*x)];
end