Description: |
Returns the location of 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. This argument is a Fortran 95
feature. | ||

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

Results: | The result
is an array of type default integer.
The following rules apply if DIM is omitted: - The array result has rank one and a size equal to the rank of ARRAY.
- If MINLOC (ARRAY) is specified, the elements in the array
result form the subscript of the location of the element with the
minimum value in ARRAY.
The
*i*th subscript returned lies in the range 1 to*e*_{i}, where*e*_{i}is the extent of the*i*th dimension of ARRAY. - If MINLOC (ARRAY, MASK=MASK) is specified, the elements in the array result form the subscript of the location of the element with the minimum value corresponding to the condition specified by MASK.
The following rules apply if DIM is specified: - The 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, MINLOC (ARRAY, DIM [,MASK]) has a
value equal to that of MINLOC (ARRAY [,MASK = MASK]). Otherwise,
the value of element (s
_{1}, s_{2}, ..., s_{DIM-1}, s_{DIM+1}, ..., s_{n}) of MINLOC (ARRAY, DIM [,MASK]) is equal to MINLOC (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 more than one element has minimum value, the element whose subscripts are returned is the first such element, taken in array element order. If ARRAY has size zero, the value of the result is undefined. |

**Examples**

The value of MINLOC ((/3, 1, 4, 1/)) is (2), which is the subscript of the location of the first occurrence of the minimum value in the rank-one array.

A is the array

[ 4 0 -3 2 ] [ 3 1 -2 6 ] [ -1 -4 5 -5 ].

MINLOC (A, MASK=A .GT. -5) has the value (3, 2) because these are the subscripts of the location of the minimum value (-4) that is greater than -5.

MINLOC (A, DIM=1) has the value (3, 3, 1, 3). 3 is the subscript of the location of the minimum value (-1) in column 1; 3 is the subscript of the location of the minimum value (-4) in column 2; and so forth.

MINLOC (A, DIM=2) has the value (3, 3, 4). 3 is the subscript of the location of the minimum value (-3) in row 1; 3 is the subscript of the location of the minimum value (-2) in row 2; and so forth.

Previous Page Next Page Table of Contents