\section{CUMSUM Cumulative Summation Function}

\subsection{Usage}

Computes the cumulative sum of an n-dimensional array along a given
dimension.  The general syntax for its use is
\begin{verbatim}
  y = cumsum(x,d)
\end{verbatim}
where \verb|x| is a multidimensional array of numerical type, and \verb|d|
is the dimension along which to perform the cumulative sum.  The
output \verb|y| is the same size of \verb|x|.  Integer types are promoted
to \verb|int32|. If the dimension \verb|d| is not specified, then the
cumulative sum is applied along the first non-singular dimension.
\subsection{Function Internals}

The output is computed via
\[
  y(m_1,\ldots,m_{d-1},j,m_{d+1},\ldots,m_{p}) = 
  \sum_{k=1}^{j} x(m_1,\ldots,m_{d-1},k,m_{d+1},\ldots,m_{p}).
\]
\subsection{Example}

The default action is to perform the cumulative sum along the
first non-singular dimension.
\begin{verbatim}
--> A = [5,1,3;3,2,1;0,3,1]
A = 
  <int32>  - size: [3 3]
 
Columns 1 to 3
 5  1  3  
 3  2  1  
 0  3  1  
--> cumsum(A)
ans = 
  <int32>  - size: [3 3]
 
Columns 1 to 3
 5  1  3  
 8  3  4  
 8  6  5  

\end{verbatim}
To compute the cumulative sum along the columns:
\begin{verbatim}
--> cumsum(A,2)
ans = 
  <int32>  - size: [3 3]
 
Columns 1 to 3
 5  6  9  
 3  5  6  
 0  3  4  

\end{verbatim}
The cumulative sum also works along arbitrary dimensions
\begin{verbatim}
--> B(:,:,1) = [5,2;8,9];
--> B(:,:,2) = [1,0;3,0]
B = 
  <int32>  - size: [2 2 2]
(:,:,1) = 
 
Columns 1 to 2
 5  2  
 8  9  
(:,:,2) = 
 
Columns 1 to 2
 1  0  
 3  0  
--> cumsum(B,3)
ans = 
  <int32>  - size: [2 2 2]
(:,:,1) = 
 
Columns 1 to 2
  5   2  
  8   9  
(:,:,2) = 
 
Columns 1 to 2
  6   2  
 11   9  

\end{verbatim}
