## TOTAL

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.

### Calling Sequence

Result = TOTAL( Array [, Dimension] )

### Arguments

#### Array

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.

#### Dimension

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:

### Keywords

#### DOUBLE

Set this keyword to perform the summation in double-precision floating-point.

#### NAN

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.)

### Example

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

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

IDL prints:

43.0000

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:

A = FINDGEN(5,5)

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

PRINT, TOTAL(A, 1)

IDL prints:

10.0000   35.0000   60.0000   85.0000   110.000

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

PRINT, TOTAL(A, 2)

IDL prints:

50.0000   55.0000   60.0000   65.0000   70.0000