root / src / blas / isamax.f @ 4
Historique | Voir | Annoter | Télécharger (1,12 ko)
1 |
INTEGER FUNCTION ISAMAX(N,SX,INCX) |
---|---|
2 |
* .. Scalar Arguments .. |
3 |
INTEGER INCX,N |
4 |
* .. |
5 |
* .. Array Arguments .. |
6 |
REAL SX(*) |
7 |
* .. |
8 |
* |
9 |
* Purpose |
10 |
* ======= |
11 |
* |
12 |
* finds the index of element having max. absolute value. |
13 |
* jack dongarra, linpack, 3/11/78. |
14 |
* modified 3/93 to return if incx .le. 0. |
15 |
* modified 12/3/93, array(1) declarations changed to array(*) |
16 |
* |
17 |
* |
18 |
* .. Local Scalars .. |
19 |
REAL SMAX |
20 |
INTEGER I,IX |
21 |
* .. |
22 |
* .. Intrinsic Functions .. |
23 |
INTRINSIC ABS |
24 |
* .. |
25 |
ISAMAX = 0 |
26 |
IF (N.LT.1 .OR. INCX.LE.0) RETURN |
27 |
ISAMAX = 1 |
28 |
IF (N.EQ.1) RETURN |
29 |
IF (INCX.EQ.1) GO TO 20 |
30 |
* |
31 |
* code for increment not equal to 1 |
32 |
* |
33 |
IX = 1 |
34 |
SMAX = ABS(SX(1)) |
35 |
IX = IX + INCX |
36 |
DO 10 I = 2,N |
37 |
IF (ABS(SX(IX)).LE.SMAX) GO TO 5 |
38 |
ISAMAX = I |
39 |
SMAX = ABS(SX(IX)) |
40 |
5 IX = IX + INCX |
41 |
10 CONTINUE |
42 |
RETURN |
43 |
* |
44 |
* code for increment equal to 1 |
45 |
* |
46 |
20 SMAX = ABS(SX(1)) |
47 |
DO 30 I = 2,N |
48 |
IF (ABS(SX(I)).LE.SMAX) GO TO 30 |
49 |
ISAMAX = I |
50 |
SMAX = ABS(SX(I)) |
51 |
30 CONTINUE |
52 |
RETURN |
53 |
END |