MAXLOC(3I) Last changed: 2-5-98
MAXLOC - Returns the location of a maximum value in an array
MAXLOC ([ARRAY=]array [,[DIM=]dim] [,[MASK=]mask])
MAXLOC ([ARRAY=]array [,[MASK=]mask])
UNICOS, UNICOS/mk, and IRIX systems
Fortran 90
The MAXLOC intrinsic function returns the location of the first
element of array having the maximum 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. This
function does a check on dim when present.
mask Must be of type logical and must be conformable with array.
MAXLOC is a transformational function. The name of this intrinsic
cannot be passed as an argument.
On UNICOS systems, both execution speed and the number of bits used in
mathematical operations are affected when compiling with
f90 -O fastint, which is the default setting. For more information,
see CF90 Commands and Directives Reference Manual, publication
SR-3901.
The result is an integer of type default integer, of rank one, with
size equal to the rank of array.
The result of MAXLOC(array) is a rank one array whose element values
are the values of the subscripts of an element of array whose value
equals the maximum value of all of the elements of array. The ith
subscript returned lies in the range 1 to e , where e is
i i
the extent of the ith dimension of array. If more than one element
has the maximum value, the element whose subscripts are returned is
the first such element, taken in array element order. If array has
size 0, the value of the result is undefined.
The result of MAXLOC(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
maximum value of all such elements of array. The ith subscript
returned lies in the range 1 to e , where e is
i i
the extent of the ith dimension of array. If more than one such
element has the maximum 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 0 or if every
element of mask has the value false), the value of the result is
undefined.
If array has rank one, the result of
MAXLOC(array, DIM=dim [, MASK=mask]) is a scalar with a value that is
the same as that of the first element of MAXLOC(array [, MASK=mask]).
Otherwise, the value of element (s , s , ..., s , s , ..., s )
1 2 dim-1 dim+1 n
of the result is equal to
MAXLOC(array(s , s , ..., s , : , s , ..., s ), DIM=1
1 2 dim-1 dim+1 n
[, MASK=mask(s , s , ..., s , : , s , ..., s )]).
1 2 dim-1 dim+1 n
An element of the result is undefined if the value cannot be
represented as an integer.
Example 1: The value of MAXLOC( (/ 2, 6, 4, 6 /) ) is [2]. If array
B is declared INTEGER, DIMENSION(4:7) :: B = (/ 8, 6, 3, 1 /), the
value of MAXLOC(B) is [1].
Example 2: Assume that A is the following array:
| 0 -5 8 -3 |
| 3 4 -1 2 |
| 1 5 6 -4 |
The following are true:
MAXLOC(A) is [1, 3]
MAXLOC(A, MASK=A .LT. 6) is [3, 2]
Using array section references, the following are true:
MAXLOC(A(2:3,2:4)) is [ 2, 2 ]
MAXLOC(A(2:3,2:4),MASK=A(2:3,2:4).LT.6) is [ 2, 1 ]
Example 3: Assume that B is the following array:
[ 100, 2, 5, 7, 1, 90, 0, 20, -1, 80 ]
The following are true of this array:
MAXLOC(B(10:1:-1)) is [ 10 ]
MAXLOC(B(10:1:-2)) is [ 3 ]
Example 4: The value of MAXLOC((/5,-9,3/)DIM=1) is 1.
Example 5: Assume that C is following array:
| 1 3 -9 |
| 2 2 6 |
The following are true of this array:
MAXLOC(C,DIM=1) is [ 2, 1, 2 ]
MAXLOC(C,DIM=2) is [ 2, 3 ]
MAXLOC(C) is [ 2, 3 ]
Intrinsic Procedures Reference Manual, publication SR-2138, for the
printed version of this man page.
MAXLOC(3I) Last changed: 2-5-98
MAXLOC - Returns the location of a maximum value in an array
MAXLOC ([ARRAY=]array [,[DIM=]dim] [,[MASK=]mask])
MAXLOC ([ARRAY=]array [,[MASK=]mask])
UNICOS, UNICOS/mk, and IRIX systems
Fortran 90
The MAXLOC intrinsic function returns the location of the first
element of array having the maximum 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. This
function does a check on dim when present.
mask Must be of type logical and must be conformable with array.
MAXLOC is a transformational function. The name of this intrinsic
cannot be passed as an argument.
On UNICOS systems, both execution speed and the number of bits used in
mathematical operations are affected when compiling with
f90 -O fastint, which is the default setting. For more information,
see CF90 Commands and Directives Reference Manual, publication
SR-3901.
The result is an integer of type default integer, of rank one, with
size equal to the rank of array.
The result of MAXLOC(array) is a rank one array whose element values
are the values of the subscripts of an element of array whose value
equals the maximum value of all of the elements of array. The ith
subscript returned lies in the range 1 to e , where e is
i i
the extent of the ith dimension of array. If more than one element
has the maximum value, the element whose subscripts are returned is
the first such element, taken in array element order. If array has
size 0, the value of the result is undefined.
The result of MAXLOC(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
maximum value of all such elements of array. The ith subscript
returned lies in the range 1 to e , where e is
i i
the extent of the ith dimension of array. If more than one such
element has the maximum 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 0 or if every
element of mask has the value false), the value of the result is
undefined.
If array has rank one, the result of
MAXLOC(array, DIM=dim [, MASK=mask]) is a scalar with a value that is
the same as that of the first element of MAXLOC(array [, MASK=mask]).
Otherwise, the value of element (s , s , ..., s , s , ..., s )
1 2 dim-1 dim+1 n
of the result is equal to
MAXLOC(array(s , s , ..., s , : , s , ..., s ), DIM=1
1 2 dim-1 dim+1 n
[, MASK=mask(s , s , ..., s , : , s , ..., s )]).
1 2 dim-1 dim+1 n
An element of the result is undefined if the value cannot be
represented as an integer.
Example 1: The value of MAXLOC( (/ 2, 6, 4, 6 /) ) is [2]. If array
B is declared INTEGER, DIMENSION(4:7) :: B = (/ 8, 6, 3, 1 /), the
value of MAXLOC(B) is [1].
Example 2: Assume that A is the following array:
| 0 -5 8 -3 |
| 3 4 -1 2 |
| 1 5 6 -4 |
The following are true:
MAXLOC(A) is [1, 3]
MAXLOC(A, MASK=A .LT. 6) is [3, 2]
Using array section references, the following are true:
MAXLOC(A(2:3,2:4)) is [ 2, 2 ]
MAXLOC(A(2:3,2:4),MASK=A(2:3,2:4).LT.6) is [ 2, 1 ]
Example 3: Assume that B is the following array:
[ 100, 2, 5, 7, 1, 90, 0, 20, -1, 80 ]
The following are true of this array:
MAXLOC(B(10:1:-1)) is [ 10 ]
MAXLOC(B(10:1:-2)) is [ 3 ]
Example 4: The value of MAXLOC((/5,-9,3/)DIM=1) is 1.
Example 5: Assume that C is following array:
| 1 3 -9 |
| 2 2 6 |
The following are true of this array:
MAXLOC(C,DIM=1) is [ 2, 1, 2 ]
MAXLOC(C,DIM=2) is [ 2, 3 ]
MAXLOC(C) is [ 2, 3 ]
Intrinsic Procedures Reference Manual, publication SR-2138, for the
printed version of this man page.
[ Back ]
|