ISMIN/IDMIN/IIMIN |
| Index of minimum element of vector |
|
| Use incx = 1 if the vector x is stored contiguously in |
|
| array x; that is, if xi is stored in x(i). Refer to “BLAS |
|
| Indexing Conventions” in the introduction to this |
|
| chapter. |
Output | i | If n ≤ 0, then i = 0. Otherwise, i is the index of the |
|
| minimum element of x. |
Fortran |
| INTEGER*4 FUNCTION ISMIN (N,X,INCX) |
Equivalent |
| REAL*4 X(*),XMIN |
|
| ISMIN = 1 |
|
| IF ( N .GT. 1 ) THEN |
|
| XMIN = X(1) |
|
| INCXA = ABS ( INCX ) |
|
| IX = 1 + INCXA |
|
| DO 10 I = 2, N |
|
| IF ( X(IX) .LT. XMIN ) THEN |
|
| ISMIN = I |
|
| XMIN = X(IX) |
|
| END IF |
|
| IX = IX + INCXA |
| 10 | CONTINUE |
|
| ELSE IF ( N .LT. 1 ) THEN |
|
| ISMIN = 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,IDMIN,N,INCX | |
REAL*8 | X(20) | |
N = | 10 |
|
INCX = 1 |
| |
I = | IDMIN | (N,X,INCX) |
52HP MLIB User’s Guide