function sum = csum(v)
% csum(v): Determine the vector of cumulative sums for vector v.

if length(v) == 0 % If v is empty...
sum = [];
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