Description: | Returns the maximum value of all elements in an array, a set of elements in an array, or elements in a specified dimension of an array. | ||

Class: |
Transformational function; Generic | ||

Arguments: |
ARRAY | Must be an array of type integer or real. | |

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

MASK (opt) | Must be a logical array that is conformable with ARRAY. | ||

Results: |
The result is an array or a scalar of the
same data type as ARRAY.
The result is scalar if DIM is omitted or ARRAY has rank one. The following rules apply if DIM is omitted: - If MAXVAL (ARRAY) is specified, the result has a value equal to the maximum value of all the elements in ARRAY.
- If MAXVAL (ARRAY, MASK=MASK) is specified, the result has a value equal to the maximum value of the elements in ARRAY corresponding to the condition specified by MASK.
The following rules apply if DIM is specified: - An array result has a rank that is one less than ARRAY,
and shape (d
_{1}, d_{2},...,d_{DIM-1}, d_{DIM+1}, ..., d_{n}), where (d_{1}, d_{2}, ..., d_{n}) is the shape of ARRAY. - If ARRAY has rank one, MAXVAL (ARRAY, DIM [,MASK]) has a
value equal to that of MAXVAL (ARRAY [,MASK = MASK]). Otherwise,
the value of element (s
_{1}, s_{2}, ..., s_{DIM-1}, s_{DIM+1}, ..., s_{n}) of MAXVAL (ARRAY, DIM, [,MASK]) is equal to MAXVAL (ARRAY (s_{1}, s_{2}, ..., s_{DIM-1}, :, s_{DIM+1}, ..., s_{n}) [,MASK = MASK (s_{1}, s_{2}, ..., s_{DIM-1}, :, s_{DIM+1}, ..., s_{n})]).
If ARRAY has size zero or if there are no true elements in MASK, the result (if DIM is omitted), or each element in the result array (if DIM is specified), has the value of the negative number of the largest magnitude supported by the processor for numbers of the type and kind parameters of ARRAY. |

**Examples**

The value of MAXVAL ((/2, 3, 4/)) is 4 because that is the maximum value in the rank-one array.

MAXVAL (B, MASK=B .LT. 0.0) finds the maximum value of the negative elements of B.

C is the array

[ 2 3 4 ] [ 5 6 7 ].

MAXVAL (C, DIM=1) has the value (5, 6, 7). 5 is the maximum value in column 1; 6 is the maximum value in column 2; and so forth.

MAXVAL (C, DIM=2) has the value (4, 7). 4 is the maximum value in row 1 and 7 is the maximum value in row 2.

Previous Page Next Page Table of Contents