| 1 |
integer function icamax(n,cx,incx) |
| 2 |
c |
| 3 |
c finds the index of element having max. absolute value. |
| 4 |
c jack dongarra, linpack, 3/11/78. |
| 5 |
c modified 3/93 to return if incx .le. 0. |
| 6 |
c modified 12/3/93, array(1) declarations changed to array(*) |
| 7 |
c |
| 8 |
complex cx(*) |
| 9 |
real smax |
| 10 |
integer i,incx,ix,n |
| 11 |
complex zdum |
| 12 |
real cabs1 |
| 13 |
cabs1(zdum) = abs(real(zdum)) + abs(aimag(zdum)) |
| 14 |
c |
| 15 |
icamax = 0 |
| 16 |
if( n.lt.1 .or. incx.le.0 ) return |
| 17 |
icamax = 1 |
| 18 |
if(n.eq.1)return |
| 19 |
if(incx.eq.1)go to 20 |
| 20 |
c |
| 21 |
c code for increment not equal to 1 |
| 22 |
c |
| 23 |
ix = 1 |
| 24 |
smax = cabs1(cx(1)) |
| 25 |
ix = ix + incx |
| 26 |
do 10 i = 2,n |
| 27 |
if(cabs1(cx(ix)).le.smax) go to 5 |
| 28 |
icamax = i |
| 29 |
smax = cabs1(cx(ix)) |
| 30 |
5 ix = ix + incx |
| 31 |
10 continue |
| 32 |
return |
| 33 |
c |
| 34 |
c code for increment equal to 1 |
| 35 |
c |
| 36 |
20 smax = cabs1(cx(1)) |
| 37 |
do 30 i = 2,n |
| 38 |
if(cabs1(cx(i)).le.smax) go to 30 |
| 39 |
icamax = i |
| 40 |
smax = cabs1(cx(i)) |
| 41 |
30 continue |
| 42 |
return |
| 43 |
end |