function im2 = ipcircshift2(im1,row,col)
%
% IPCIRCSHIFT2 - circular shift of a matrix
% zero is top left, positive m and n shift down and right
% function im2 = ipcircshift2(im1,row,col)
%
im2 = im1;
sz = size(im2);
col = -col;
row = -row;
if (col > 0)
  im2 = [im2(:,(col+1):sz(2))   im2(:,1:col)];
elseif (col < 0)
  im2 = [im2(:,(sz(2) + col + 1):sz(2)) im2(:,1:(col + sz(2)))];
end 
 
if (row > 0)
    im2 = [im2((row+1):sz(1),:);  im2(1:row,:)];
elseif (row < 0)
  im2 = [im2((sz(1) + row + 1):sz(1),:); im2(1:(row + sz(1)),:)];
end
