| 1 |
/* ./src_f77/idamax.f -- translated by f2c (version 20030320). |
| 2 |
You must link the resulting object file with the libraries: |
| 3 |
-lf2c -lm (in that order) |
| 4 |
*/ |
| 5 |
|
| 6 |
#include <punc/vf2c.h> |
| 7 |
|
| 8 |
integer idamax_(integer *n, doublereal *dx, integer *incx) |
| 9 |
{ |
| 10 |
/* System generated locals */ |
| 11 |
integer ret_val, i__1; |
| 12 |
doublereal d__1; |
| 13 |
|
| 14 |
/* Local variables */ |
| 15 |
static integer i__, ix; |
| 16 |
static doublereal dmax__; |
| 17 |
|
| 18 |
|
| 19 |
/* finds the index of element having max. absolute value. */ |
| 20 |
/* jack dongarra, linpack, 3/11/78. */ |
| 21 |
/* modified 3/93 to return if incx .le. 0. */ |
| 22 |
/* modified 12/3/93, array(1) declarations changed to array(*) */ |
| 23 |
|
| 24 |
|
| 25 |
/* Parameter adjustments */ |
| 26 |
--dx; |
| 27 |
|
| 28 |
/* Function Body */ |
| 29 |
ret_val = 0; |
| 30 |
if (*n < 1 || *incx <= 0) { |
| 31 |
return ret_val; |
| 32 |
} |
| 33 |
ret_val = 1; |
| 34 |
if (*n == 1) { |
| 35 |
return ret_val; |
| 36 |
} |
| 37 |
if (*incx == 1) { |
| 38 |
goto L20; |
| 39 |
} |
| 40 |
|
| 41 |
/* code for increment not equal to 1 */ |
| 42 |
|
| 43 |
ix = 1; |
| 44 |
dmax__ = abs(dx[1]); |
| 45 |
ix += *incx; |
| 46 |
i__1 = *n; |
| 47 |
for (i__ = 2; i__ <= i__1; ++i__) { |
| 48 |
if ((d__1 = dx[ix], abs(d__1)) <= dmax__) { |
| 49 |
goto L5; |
| 50 |
} |
| 51 |
ret_val = i__; |
| 52 |
dmax__ = (d__1 = dx[ix], abs(d__1)); |
| 53 |
L5: |
| 54 |
ix += *incx; |
| 55 |
/* L10: */ |
| 56 |
} |
| 57 |
return ret_val; |
| 58 |
|
| 59 |
/* code for increment equal to 1 */ |
| 60 |
|
| 61 |
L20: |
| 62 |
dmax__ = abs(dx[1]); |
| 63 |
i__1 = *n; |
| 64 |
for (i__ = 2; i__ <= i__1; ++i__) { |
| 65 |
if ((d__1 = dx[i__], abs(d__1)) <= dmax__) { |
| 66 |
goto L30; |
| 67 |
} |
| 68 |
ret_val = i__; |
| 69 |
dmax__ = (d__1 = dx[i__], abs(d__1)); |
| 70 |
L30: |
| 71 |
; |
| 72 |
} |
| 73 |
return ret_val; |
| 74 |
} /* idamax_ */ |
| 75 |
|