Description: |
Counts the number of true elements in an entire array or in a specified dimension of an array. | ||

Class: |
Transformational function; Generic | ||

Arguments: | MASK | Must be a logical array. | |

DIM (opt) | Must be a scalar integer expression
with a value in the range 1 to n, where n is the rank
of MASK. | ||

Results: |
The result is an array or scalar of type
default integer.
The result is scalar if DIM is omitted or MASK has rank one. A scalar result has a value equal to the number of true elements of MASK. If MASK has size zero, the result is zero.
An array result has a rank that is one less than MASK, and shape
(d
Each element in an array result equals the number of elements that
are true in the one dimensional array defined by MASK (s |

**Examples**

COUNT ((/.TRUE., .FALSE., .TRUE./)) has the value 2 because two elements are true.

COUNT ((/.TRUE., .TRUE., .TRUE./)) has the value 3 because three elements are true.

A is the array

[ 1 5 7 ] [ 3 6 8 ]and B is the array

[ 0 5 7 ] [ 2 6 9 ].

COUNT (A .NE. B, DIM=1) tests to see how many elements in each column of A are not equal to the elements in the corresponding column of B. The result has the value (2, 0, 1) because:

- The first column of A and B have 2 elements that are not equal.
- The second column of A and B have 0 elements that are not equal.
- The third column of A and B have 1 element that is not equal.

COUNT (A .NE. B, DIM=2) tests to see how many elements in each row of A are not equal to the elements in the corresponding row of B. The result has the value (1, 2) because:

- The first row of A and B have 1 element that is not equal.
- The second row of A and B have 2 elements that are not equal.

Previous Page Next Page Table of Contents