minloc(3I)

MINLOC - Returns the location of a minimum value in an array

As shipped in IRIX 6.5.22. Last changed in IRIX 6.5.19.

NAME
     MINLOC - Returns the location of a minimum value in an array

SYNOPSIS
     MINLOC ([ARRAY=]array [,[DIM=]dim] [,[MASK=]mask])

STANDARDS
     Fortran

DESCRIPTION
     The MINLOC intrinsic function can be used for array location.  It
     returns the location of the first element of array that has the
     minimum value of the elements identified by mask.  It accepts the
     following arguments:

     array     Must be of type integer or real.  It must not be scalar.

     dim       Must be a scalar integer value in the range 1 <= dim <= n,
               where n is the rank of array.  The corresponding actual
               argument must not be an optional dummy argument.

     mask      Must be of type logical and must be conformable with array.

     MINLOC is a transformational function.  The name of this intrinsic
     cannot be passed as an argument.

RETURN VALUES
     The result is an integer array of type default integer, of rank one,
     with size equal to the rank of array.

     The result of MINLOC(array) is a rank-one array whose element values
     are the values of the subscripts of an element of array whose value
     equals the minimum value of all of the elements of array.  The ith
     subscript returned lies in the range 1 to ei,

     where ei
     is the extent of the ith dimension of array.  If more than one element
     has the 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.

     The result of MINLOC(array,MASK=mask) is a rank-one array whose
     element values are the values of the subscripts of an element of
     array, corresponding to a true element of mask whose value equals the
     minimum value of all such elements of array.  The ith subscript
     returned lies in the range 1 to ei,

     where ei
     is the extent of the ith dimension of array.  If more than one such
     element has the minimum value, the element whose subscripts are
     returned is the first such element taken in array element order.  If
     there are no such elements (that is, if array has size zero or every
     element of mask has the value false), the value of the result is
     undefined.

     If array has rank one, the result of
     MINLOC(array, DIM=dim [, MASK=mask]) is a scalar with a value that is
     the same as that of the first element of MINLOC(array [, MASK=mask]).
     Otherwise, the value of element (s1, s2, ..., sdim-1, sdim+1, ..., sn)

     of the result is equal to
     MINLOC(array(s1, s2, ..., sdim-1, : , sdim+1, ..., sn), DIM=1

     [, MASK=mask(s1, s2, ..., sdim-1, : , sdim+1, ..., sn)]).

     An element of the result is undefined if the value cannot be
     represented as an integer.

EXAMPLES
     Example 1:  MINLOC((/4,3,6,3/)) yields [2].

     Example 2:  Assume that array B is declared as follows:

          INTEGER, DIMENSION(4:7) :: B = (/8,6,3,1/)

     MINLOC(B) yields [4].

     Example 3:  Assume that array A is as follows:

     | 0 -5  8 -3 |
     | 3  4 -1  2 |
     | 1  5  6 -4 |

     The following are true:

     * MINLOC(A) yields [1,2].

     * MINLOC(A,MASK=A.GT.-4) yields [1,4].

     Using array section references, the following are true:

     * MINLOC(A(2:3,2:4)) yields [2,3].

     * MINLOC(A(2:3,2:4),MASK=A(2:3,2:4).GT.-4) yields [1,2].

     Example 4:  Assume that B is array [100,2,5,7,1,90,0,20,-1,80].

     The following are true:

     * MINLOC(B(10:1:-1)) yields 2.

     * MINLOC(B(10:1:-2)) yields 5.

     Example 5:  MINLOC((/5,-9,3/),DIM=1) yields 2.

     Example 6:  Assume that C is the following array:

     | 1 3 -9 |
     | 2 2  6 |

     The following are true of this array:

     * MINLOC(C,DIM=1) yields [1,2,1].

     * MINLOC(C,DIM=2) yields [3,1].

     * MINLOC(C) yields [3,1].