maxval
- Date:
10-12-2011
NAME
MAXVAL - Returns the maximum value in an array
SYNOPSIS
MAXVAL([ARRAY=]array [,[DIM=]dim][,[MASK=]mask])
IMPLEMENTATION
Cray Linux Environment (CLE)
STANDARDS
Fortran
DESCRIPTION
The MAXVAL intrinsic function can be used for array reduction. It returns the maximum value of the elements of array along dimension dim corresponding to the true elements of mask.
It accepts the following arguments:
- array
Must be of type integer, real, or character. 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
This optional argument must be of type logical and must be conformable with array.
MAXVAL is a transformational intrinsic function. The name of this intrinsic cannot be passed as an argument.
RETURN VALUES
The result is of the same type as array. It is scalar if dim is absent or array has rank one. Otherwise, the result is an array of rank n-1 and of this shape:
(d1, d2, ..., ddim-1, ddim+1, ..., dn)
where:
(d1, d2, ..., dn)
is the shape of array.
The result of MAXVAL(array) has a value equal to the maximum value of all the elements of array if the size of the array is not zero. If the array has size zero and is type integer or real, the result has the value of the negative number of the largest magnitude supported for numbers of the data type of array. If array has size zero and is type character, the result has the value of a string of characters of length LEN(array), with each character equal to CHAR(0).
The result of MAXVAL(array,MASK=mask) has a value equal to the maximum value of all the elements of array corresponding to true elements of mask if the size of array is not zero. If the array has size zero and is type integer or real and has no true elements, the result has the value of the negative number of the largest magnitude supported for numbers of the data type of array if there are no true elements. If array has size zero and is type character and has no true elements, the result has the value of a string of characters of length LEN(array), with each character equal to CHAR(0).
If array has rank one, MAXVAL(array,dim[,mask]) has a value equal to that of MAXVAL(array[,MASK=mask]). Otherwise, the value of element
(s1, s2, ..., sdim-1, sdim+1, ..., sn)
of MAXVAL(array,dim[,mask]) is equal to
MAXVAL(array(s1, s2, ..., sdim-1, : , sdim+1, ..., sn)
[, MASK=mask(s1, s2, ..., sdim-1, : , sdim+1, ..., sn)])
EXAMPLES
Example 1:
MAXVAL((/1,2,3/)) yields 3
Example 2:
Assume that C is array [10,-100,10]. Then MAXVAL(C,MASK=C.LT.0.0) finds the maximum of the negative elements of C (which is -100) and MAXVAL(C,MASK=C.GT.10) returns a negative number of the largest possible integer because there are no true elements using the mask.
Example 3:
Assume that B is the following array:
| 1 3 5 |
| 2 4 6 |
The following are true:
MAXVAL(B,DIM=1) yields [2,4,6].
MAXVAL(B,DIM=2) yields [5,6].
MAXVAL(B) yields 6.
Example 4:
Assume that N is the following array:
| 0 1 2 3 |
| 4 5 6 7 |
| 8 9 0 1 |
The following are true:
MAXVAL(N(2:3,2:4),MASK=N(2:3,2:4).NE.0) yields 9.
MAXVAL(N(2:3,2:4),DIM=1,N(2:3,2:4).NE.0) yields [9,6,7].
MAXVAL(N(2:3,2:4),DIM=2,N(2:3,2:4).NE.0) yields [7,9].