function y=hshift(x,n)
% y=hshift(x,n)
%
% Shift the matrix x horizontally to the right by n columns circulary.
% If n is negative, the shift is to the left.

N=size(x,2);

if n>=0
  y=[x(: , N-n+1:N) x(: , 1:N-n)];
else
  n=abs(n);
  y=[x(: , n+1:N) x(: , 1:n)];
end