The
TOTAL function returns the
sum of the elements of *
Array*
. The sum of the array elements over a given dimension is returned if the *
Dimension*
argument is present.

The array to be summed. This array can be of any basic type except string. If *
Array*
is double-precision floating-point, complex, or double-precision complex, the result is of the same type. Otherwise, the result is single-precision floating-point.

The dimension over which to sum, starting at one. If this argument is not present or zero, the scalar sum of all the array elements is returned. If this argument is present, the result is an array with one less dimension than *
Array*
. For example, if the dimensions of *
Array*
are *
N*
_{
1}
, *
N*
_{
2}
, *
N*
_{
3}
, and *
Dimension*
is 2, the dimensions of the result are (*
N*
_{
1}
, *
N*
_{
3}
), and element *
(i,j)*
of the result contains the sum:

Set this keyword to cause the routine to check for occurrences of the IEEE floating-point value NaN in the input data. Elements with the value NaN are treated as missing data. (See Special Floating-Point Values for more information on IEEE floating-point values.)

Sum the elements of the array [20, 10, 5, 5, 3] and print the result by entering:

PRINT, TOTAL([20, 10, 5, 5, 3])

When a multi-dimensional array is used, the results are different, as shown in the following example. Create a five-element by five-element array filled with floating-point values by entering:

Display the sums of each of the rows in A by entering:

10.0000 35.0000 60.0000 85.0000 110.000