SMAX/DMAX/IMAX |
| Maximum of vector |
|
| Indexing Conventions” in the introduction to this |
|
| chapter. |
Output | s | If n ≤ 0, then s = −∞, the most negative representable |
|
| machine number. Otherwise, s is the maximum of the |
|
| elements of x. |
Fortran Equivalent
REAL*4 FUNCTION SMAX (N,X,INCX) REAL*4 X(*)
SMAX = - ∞
INCXA = ABS ( INCX ) IX = 1
DO 10 I = 1, N
SMAX = MAX ( SMAX , X(IX) )
IX = IX + INCXA
10CONTINUE RETURN END
Example Compute the maximum of the elements of REAL*8 vector x, where x is a vector 10 elements long stored in a
INTEGER*4 | N,INCX | |
REAL*8 | S,DMAX,X(20) | |
N = | 10 |
|
INCX = 1 |
| |
S = | DMAX (N,X,INCX) |
104HP MLIB User’s Guide