Search vector for element | ISSVxx/IDSVxx/IISVxx/ICSVxx/IZSVxx | |
Output | i | If n ≤ 0 or if no element of x satisfies the relationship |
|
| with a specified by the subprogram name, then i = 0. |
|
| Otherwise, i is the index i of the first element xi of x |
|
| that satisfies the relationship with a specified by the |
|
| subprogram name. Recall that xi is stored in |
|
| x((i−1)⋅incx+1). |
Fortran | INTEGER*4 FUNCTION IISVEQ (N, X,INCX, A) | |
Equivalent | INTEGER*4 X(*),A | |
| IISVEQ = 0 |
|
| INCXA = ABS ( INCX ) | |
| IX = 1 |
|
| DO 10 I = 1, N | |
| IF ( X(IX) .EQ. A ) THEN | |
| IISVEQ = I | |
| RETURN | |
| END IF |
|
| IX = IX + INCXA | |
| 10 CONTINUE |
|
| RETURN |
|
| END |
|
Example | Search for the first positive element of a REAL*8 vector x, where x is a vector | |
| 10 elements long stored in a | |
| INTEGER*4 I,IDSVGT,N,INCX | |
| REAL*8 | A,X(20) |
| N = 10 |
|
| INCX = 1 |
|
| A = 0.0D0 |
|
I = IDSVGT (N,X,INCX,A)
Chapter 2 Basic Vector Operations 55