SAMAX/DAMAX/IAMAX/SCAMAX/DZAMAX

Maximum of magnitudes

Fortran Equivalent

REAL*4 FUNCTION SAMAX (N,X,INCX) REAL*4 X(*)

SAMAX = 0.0

INCXA = ABS ( INCX ) IX = 1

DO 10 I = 1, N

SAMAX = MAX ( SAMAX , ABS ( X(IX) ) )

IX = IX + INCXA

10CONTINUE RETURN END

Example Compute the maximum of the magnitudes of the elements of a REAL*8 vector x, where x is a vector 10 elements long stored in a one-dimensional array X of dimension 20.

INTEGER*4

N,INCX

REAL*8

S,DAMAX,X(20)

N =

10

 

INCX = 1

 

S =

DAMAX

(N,X,INCX)

58HP MLIB User’s Guide