Returns the sum of the elements of a matrix.

*[A]* - the matrix whose elements you want to sum

*Ans* - the sum of the matrix elements

[A], L₁, Ans

TI-83/84/+/SE

zada

*URL:* United TI

:dim([A]

:Matr►list(cumSum([A])^{T},Ans(1),L₁

:sum(L₁

The cumSum( command gets the cumulative sum of each column in the matrix, adding the value of the previous element to the next element, and repeating this for each consecutive element in the column. When the cumSum( command is finished, the last element in each column will contain the sum of that column. Taking the ^{T} (transpose) of the resulting matrix switches columns and rows.

Then, using the Matr►list( command, the last column of this result is stored to L₁. This column was originally the last row of cumSum('s output, so it contains all the column sums. Finally, by calculating the sum of that list, we get the total of the matrix elements. L₁ is no longer necessary, and can be deleted.

If you want to use the sum for future use, you can store it to a more permanent variable, such as A or X. When you are done using [A], you should clean it up at the end of your program.

.