function y = sinc (x)
% USAGE
%        y = sinc(x)
% 
% computes sinc(x) = sin(pi*x)/(pi*x), if x ~= 0
%          sinc(0) = 1 
% 
% R Kakarala
% UCBX 

  y = ones (size (x));     % initial output to 1, to cover case when x=0
  i = (x ~= 0);            % find all places where x is not zero
  
  y(i) = sin(pi*x(i)) ./ (pi*x(i));   % for the nonzero values of x, compute sinc.
                           % note that if x=0, the value of has already
                           % been inserted.