function d=shift(c,theta)
%
% shift :: Function that computes a spatial pattern that is shifted by one
% unit in a given direction of a given pattern
%
%% Variables
% c :: Input spatial pattern
%
% theta :: Direction (in radians) opposite to that of the shift
%
% d :: Output spatial pattern
%
%% Reference
% Grossberg, S. and Pilly, P. K. (2008). Temporal dyanamics of decision-making during motion perception in the visual cortex. Vision Research, 48(12), 1345-1373.
%
%% Author
% Praveen K. Pilly (advaitp@gmail.com)
%
%% License policy
% Written by Praveen K. Pilly, Department of Cognitive and Neural Systems, Boston University
% Copyright 2009, Trustees of Boston University
%
% Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted
% without fee, provided that the above copyright notice and this permission notice appear in all copies, derivative works and
% associated documentation, and that neither the name of Boston University nor that of the author(s) be used in advertising or
% publicity pertaining to the distribution or sale of the software without specific, prior written permission. Neither Boston
% University nor its agents make any representations about the suitability of this software for any purpose. It is provided "as
% is" without warranty of any kind, either express or implied. Neither Boston University nor the author indemnify any
% infringement of copyright, patent, trademark, or trade secret resulting from the use, modification, distribution or sale of
% this software.
%
%% Last modified
% June 25, 2009
%%
x1=cos(theta+pi-pi/2);
y1=sin(theta+pi-pi/2);
% MATLAB sometimes gives weird answers
% For example, sin(pi/2+pi/2) = 1.2246e-016 instead of 0
% And sign(sin(pi/2+pi/2)) = 1 instead of 0
if abs(x1)<10^(-15)
x1=0;
end
if abs(y1)<10^(-15)
y1=0;
end
x=sign(x1);
y=sign(y1);
[m,n]=size(c);
for i=1:m
for j=1:n
if (1<=i+x)&(i+x<=m)&(1<=j+y)&(j+y<=n)
d(i,j)=c(i+x,j+y);
else
d(i,j)=0;
end
end
end
return