Dear Eloy, thanks for the bug report. There is a bug, but actually the bug is
not in the code but it is in the comments of the code. The routine ICMAX1 finds
the index of the first vector element of maximum absolute value. (And this is
not what the comment of the code is saying as you correctly points out.) There
is a historical reason for this comment mistake. (Related to us by Nick
Higham.) So the ICMAX1 routine initially was computing the index of the vector
element whose real part has maximum absolute value, (as the comments are
currently saying,) then we changed the routine so that it computes the index of
the vector element of maximum absolute value, and of course, forgot to change
the comments. Yup. A classic. Anyway. The comments are now corrected in our SVN
repository and should be out with the next LAPACK release. I am curious: do you
need a routine to the index of the vector element whose real part has maximum
absolute value (??)? I assume not and this was just curiosity on your part. Oh
and just to be clear, there is the ICAMAX function in the BLAS, this one works
on  Re( . )  +  Im( . ) . The ICMAX1 function in LAPACK works on  .  (so
the ?genuine? absolute value of a complex number). We tried to make this
distinction clearer in the new commit. Good continuation with SLEPc, this is a
great package and much appreciated by the community. Cheers, Julien.
On Feb 4, 2014, at 4:13 AM, Eloy Romero Alcalde <elroal@Domain.Removed> wrote:
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(100I))
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
_______________________________________________
Lapack mailing list
Lapack@Domain.Removed
http://lists.eecs.utk.edu/mailman/listinfo/lapack
