LAPACK Archives

[Lapack] Possible bug in function icmax1

Dear LAPACK team,

The documentation of the function icmax1 says that it "finds the index 
of the vector element whose real part has maximum absolute value", but I 
think that it returns the index of the element with maximum absolute 
value taking into account the imaginary part also. The next code tests 
icmax1 with the complex array 1+99i, 2+98i, ..., 10+90i. The function 
returns 1 using a LAPACK compiled with gfortran 4.6.3.

       INTEGER ICMAX1
       EXTERNAL ICMAX1

       INTEGER INCX, N, R, I
       COMPLEX CX(10)
       INCX = 1
       N = 10
       DO 100 I=1,10
         CX(I) = CMPLX(REAL(I), REAL(100-I))
  100  CONTINUE

       R = ICMAX1(N, CX, INCX)
       WRITE( *, * ) ' Result: ',R
       END

My guess is that the problem is in the definition of the statement 
function CABS1 in line 112 in icmax1.f:
*     NEXT LINE IS THE ONLY MODIFICATION.
       CABS1( ZDUM ) = ABS( ZDUM )
*     ..

If it is replaced by the next one, the above code returns 10.
*     NEXT LINE IS THE ONLY MODIFICATION.
       CABS1( ZDUM ) = ABS( REAL(ZDUM) )
*     ..

Possibly, there is a similar bug in the sister function izmax1.

Regards,
Eloy Romero

<Prev in Thread] Current Thread [Next in Thread>


For additional information you may use the LAPACK/ScaLAPACK Forum.
Or one of the mailing lists, or