9.3.102 MINVAL (ARRAY [, DIM] [, MASK])

Description:  Returns the minimum 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 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 MINVAL (ARRAY) is specified, the result has a value equal to the minimum value of all the elements in ARRAY.

  • If MINVAL (ARRAY, MASK=MASK) is specified, the result has a value equal to the minimum 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, MINVAL (ARRAY, DIM [,MASK]) has a value equal to that of MINVAL (ARRAY [,MASK = MASK]). Otherwise, the value of element (s1, s2, ..., sDIM-1, sDIM+1, ..., sn) of MINVAL (ARRAY, DIM, [,MASK]) is equal to MINVAL (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 positive number of the largest magnitude supported by the processor for numbers of the type and kind parameters of ARRAY. 

Examples

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

The value of MINVAL (B, MASK=B .GT. 0.0) finds the minimum value of the positive elements of B.

C is the array

  [ 2  3  4 ]
  [ 5  6  7 ].
 
MINVAL (C, DIM=1) has the value (2, 3, 4). 2 is the minimum value in column 1; 3 is the minimum value in column 2; and so forth.

MINVAL (C, DIM=2) has the value (2, 5). 2 is the minimum value in row 1 and 5 is the minimum value in row 2.


Previous Page Next Page Table of Contents