Index of minimum of magnitudes | ISAMIN/IDAMIN/IIAMIN/ICAMIN/IZAMIN |
Fortran Equivalent
INTEGER*4 FUNCTION ISAMIN (N,X,INCX) REAL*4 X(*),TEMP,XMIN
ISAMIN = 1
IF ( N .GT. 1 ) THEN XMIN = ABS ( X(1) ) INCXA = ABS ( INCX ) IX = 1 + INCXA
DO 10 I = 2, N
TEMP = ABS ( X(IX) )
IF ( TEMP .LT. XMIN ) THEN ISAMIN = I
XMIN = TEMP END IF
IX = IX + INCXA
10 CONTINUE
ELSE IF ( N .LT. 1 ) THEN ISAMIN = 0
END IF
RETURN END
Example Locate the smallest element of a REAL*8 vector x, where x is a vector 10 elements long stored in a
INTEGER*4 | I,IDAMIN,N,INCX | |
REAL*8 | X(20) | |
N = | 10 |
|
INCX = 1 |
| |
I = | IDAMIN (N,X,INCX) |
Chapter 2 Basic Vector Operations 45