function y = sparseact(I,J,a,n,x)
% A MATLAB function doing something interesting
% First check arguments for consistency 
N = length(I);
if ((length(J) ~= N) || (length(a) ~= N))
  error('size mismatch'); 
end
m = length(x);
if (max(I) > n), error('size mismatch'); end 
if (max(J) > m), error('size mismatch'); end

% The real thing
y = zeros(n,1); 
for k=1:N, y(I(k)) = y(I(k)) + a(k)*x(J(k)); end
