Summation Functions: Sum(), Sumsq(), Cusum()

These functions form different kinds of sums of the elements of a matrix. Sum() sums the elements of a matrix. The default is to sum all of the elements and return a 1x1 matrix. The optional parameter marg may be set to ROWS or COLUMNS, to sum across rows or columns respectively. Setting marg=ROWS produces a 1xc matrix of column sums. Setting marg=COLUMNS produces an rx1 matrix of row sums.

Sumsq() functions as does Sum(), but produces sums of squared elements.

Cusum() forms a running total across rows. It procedes row-wise through a matrix and replaces each element by the current accumulated total.