| 1 |
/* ./src_f77/icamax.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 icamax_(integer *n, realcomplex *cx, integer *incx) |
| 9 |
{ |
| 10 |
/* System generated locals */ |
| 11 |
integer ret_val, i__1, i__2; |
| 12 |
real r__1, r__2; |
| 13 |
|
| 14 |
/* Builtin functions */ |
| 15 |
double r_imag(realcomplex *); |
| 16 |
|
| 17 |
/* Local variables */ |
| 18 |
static integer i__, ix; |
| 19 |
static real smax; |
| 20 |
|
| 21 |
|
| 22 |
/* finds the index of element having max. absolute value. */ |
| 23 |
/* jack dongarra, linpack, 3/11/78. */ |
| 24 |
/* modified 3/93 to return if incx .le. 0. */ |
| 25 |
/* modified 12/3/93, array(1) declarations changed to array(*) */ |
| 26 |
|
| 27 |
|
| 28 |
/* Parameter adjustments */ |
| 29 |
--cx; |
| 30 |
|
| 31 |
/* Function Body */ |
| 32 |
ret_val = 0; |
| 33 |
if (*n < 1 || *incx <= 0) { |
| 34 |
return ret_val; |
| 35 |
} |
| 36 |
ret_val = 1; |
| 37 |
if (*n == 1) { |
| 38 |
return ret_val; |
| 39 |
} |
| 40 |
if (*incx == 1) { |
| 41 |
goto L20; |
| 42 |
} |
| 43 |
|
| 44 |
/* code for increment not equal to 1 */ |
| 45 |
|
| 46 |
ix = 1; |
| 47 |
smax = (r__1 = cx[1].r, dabs(r__1)) + (r__2 = r_imag(&cx[1]), dabs(r__2)); |
| 48 |
ix += *incx; |
| 49 |
i__1 = *n; |
| 50 |
for (i__ = 2; i__ <= i__1; ++i__) { |
| 51 |
i__2 = ix; |
| 52 |
if ((r__1 = cx[i__2].r, dabs(r__1)) + (r__2 = r_imag(&cx[ix]), dabs( |
| 53 |
r__2)) <= smax) { |
| 54 |
goto L5; |
| 55 |
} |
| 56 |
ret_val = i__; |
| 57 |
i__2 = ix; |
| 58 |
smax = (r__1 = cx[i__2].r, dabs(r__1)) + (r__2 = r_imag(&cx[ix]), |
| 59 |
dabs(r__2)); |
| 60 |
L5: |
| 61 |
ix += *incx; |
| 62 |
/* L10: */ |
| 63 |
} |
| 64 |
return ret_val; |
| 65 |
|
| 66 |
/* code for increment equal to 1 */ |
| 67 |
|
| 68 |
L20: |
| 69 |
smax = (r__1 = cx[1].r, dabs(r__1)) + (r__2 = r_imag(&cx[1]), dabs(r__2)); |
| 70 |
i__1 = *n; |
| 71 |
for (i__ = 2; i__ <= i__1; ++i__) { |
| 72 |
i__2 = i__; |
| 73 |
if ((r__1 = cx[i__2].r, dabs(r__1)) + (r__2 = r_imag(&cx[i__]), dabs( |
| 74 |
r__2)) <= smax) { |
| 75 |
goto L30; |
| 76 |
} |
| 77 |
ret_val = i__; |
| 78 |
i__2 = i__; |
| 79 |
smax = (r__1 = cx[i__2].r, dabs(r__1)) + (r__2 = r_imag(&cx[i__]), |
| 80 |
dabs(r__2)); |
| 81 |
L30: |
| 82 |
; |
| 83 |
} |
| 84 |
return ret_val; |
| 85 |
} /* icamax_ */ |
| 86 |
|