function sum = csum(v)
% csum(v): Determine the vector of cumulative sums for vector v.

% Written by Paul Chew for CS100M, Feb 2006

if length(v) == 0   % If v is empty...
    sum = v;
    return          % We return the empty vector
end
sum = zeros(1, length(v));
sum(1) = v(1);
for k = 2:length(v)
    sum(k) = sum(k-1) + v(k);
end
