|
kusano |
7d535a |
#include "f2c.h"
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
integer icamax_(integer *n, complex *cx, integer *incx)
|
|
kusano |
7d535a |
{
|
|
kusano |
7d535a |
/* System generated locals */
|
|
kusano |
7d535a |
integer ret_val, i__1, i__2;
|
|
kusano |
7d535a |
real r__1, r__2;
|
|
kusano |
7d535a |
/* Builtin functions */
|
|
kusano |
7d535a |
double r_imag(complex *);
|
|
kusano |
7d535a |
/* Local variables */
|
|
kusano |
7d535a |
static real smax;
|
|
kusano |
7d535a |
static integer i, ix;
|
|
kusano |
7d535a |
/* finds the index of element having max. absolute value.
|
|
kusano |
7d535a |
jack dongarra, linpack, 3/11/78.
|
|
kusano |
7d535a |
modified 3/93 to return if incx .le. 0.
|
|
kusano |
7d535a |
modified 12/3/93, array(1) declarations changed to array(*)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Parameter adjustments
|
|
kusano |
7d535a |
Function Body */
|
|
kusano |
7d535a |
#define CX(I) cx[(I)-1]
|
|
kusano |
7d535a |
ret_val = 0;
|
|
kusano |
7d535a |
if (*n < 1 || *incx <= 0) {
|
|
kusano |
7d535a |
return ret_val;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
ret_val = 1;
|
|
kusano |
7d535a |
if (*n == 1) {
|
|
kusano |
7d535a |
return ret_val;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
if (*incx == 1) {
|
|
kusano |
7d535a |
goto L20;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
/* code for increment not equal to 1 */
|
|
kusano |
7d535a |
ix = 1;
|
|
kusano |
7d535a |
smax = (r__1 = CX(1).r, dabs(r__1)) + (r__2 = r_imag(&CX(1)), dabs(r__2));
|
|
kusano |
7d535a |
ix += *incx;
|
|
kusano |
7d535a |
i__1 = *n;
|
|
kusano |
7d535a |
for (i = 2; i <= *n; ++i) {
|
|
kusano |
7d535a |
i__2 = ix;
|
|
kusano |
7d535a |
if ((r__1 = CX(ix).r, dabs(r__1)) + (r__2 = r_imag(&CX(ix)), dabs(
|
|
kusano |
7d535a |
r__2)) <= smax) {
|
|
kusano |
7d535a |
goto L5;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
ret_val = i;
|
|
kusano |
7d535a |
i__2 = ix;
|
|
kusano |
7d535a |
smax = (r__1 = CX(ix).r, dabs(r__1)) + (r__2 = r_imag(&CX(ix)),
|
|
kusano |
7d535a |
dabs(r__2));
|
|
kusano |
7d535a |
L5:
|
|
kusano |
7d535a |
ix += *incx;
|
|
kusano |
7d535a |
/* L10: */
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
return ret_val;
|
|
kusano |
7d535a |
/* code for increment equal to 1 */
|
|
kusano |
7d535a |
L20:
|
|
kusano |
7d535a |
smax = (r__1 = CX(1).r, dabs(r__1)) + (r__2 = r_imag(&CX(1)), dabs(r__2));
|
|
kusano |
7d535a |
i__1 = *n;
|
|
kusano |
7d535a |
for (i = 2; i <= *n; ++i) {
|
|
kusano |
7d535a |
i__2 = i;
|
|
kusano |
7d535a |
if ((r__1 = CX(i).r, dabs(r__1)) + (r__2 = r_imag(&CX(i)), dabs(
|
|
kusano |
7d535a |
r__2)) <= smax) {
|
|
kusano |
7d535a |
goto L30;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
ret_val = i;
|
|
kusano |
7d535a |
i__2 = i;
|
|
kusano |
7d535a |
smax = (r__1 = CX(i).r, dabs(r__1)) + (r__2 = r_imag(&CX(i)), dabs(
|
|
kusano |
7d535a |
r__2));
|
|
kusano |
7d535a |
L30:
|
|
kusano |
7d535a |
;
|
|
kusano |
7d535a |
}
|
|
kusano |
7d535a |
return ret_val;
|
|
kusano |
7d535a |
} /* icamax_ */
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|