9.3.97 MAXVAL (ARRAY [, DIM] [, MASK])

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 a 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 (d1, d2,...,dDIM-1, dDIM+1, ..., dn), where (d1, d2, ..., dn) 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 (s1, s2, ..., sDIM-1, sDIM+1, ..., sn) of MAXVAL (ARRAY, DIM, [,MASK]) is equal to MAXVAL (ARRAY (s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn) [,MASK = MASK (s1, s2, ..., sDIM-1, :, sDIM+1, ..., sn)]).
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