Visible to Intel only — GUID: GUID-7312420E-D0B8-4A37-A83B-430FB7AC3287
Visible to Intel only — GUID: GUID-7312420E-D0B8-4A37-A83B-430FB7AC3287
MINVAL
Transformational Intrinsic Function (Generic): 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.
result = MINVAL (array [, mask])
result = MINVAL (array, dim [, mask])
array |
(Input) Must be an array of type integer, real, or character. |
dim |
(Input) Must be a scalar integer with a value in the range 1 to n, where n is the rank of array. |
mask |
(Input; optional) Must be a logical array that is conformable with array. |
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 not specified:
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.
If array is of type character, the comparison is done using the ASCII collating sequence.
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.
The following shows another example:
INTEGER array(2, 3), i(2), minv
INTEGER, ALLOCATABLE :: AR1(:), AR2(:)
array = RESHAPE((/1, 4, 5, 2, 3, 6/), (/2, 3/))
! array is 1 5 3
! 4 2 6
i = SHAPE(array) ! i = [2 3]
ALLOCATE(AR1(i(2))) ! dimension AR1 to number of
! elements in dimension 2
! (a column) of array.
ALLOCATE(AR2(i(1))) ! dimension AR2 to number of
! elements in dimension 1
! (a row) of array
minv = MINVAL(array, MASK = array .GT. 4) ! returns 5
AR1 = MINVAL(array, DIM = 1) ! returns [ 1 2 3 ]
AR2 = MINVAL(array, DIM = 2) ! returns [ 1 2 ]
END