LAPACK Archives

### [Lapack] mistake in BLAS/scabs1.f

 ```Hi Vitaly, The definition of absolute value, abs( z ), of a complex number, z, in the BLAS has always been abs( z ) = | Re( z ) | + | Im ( z ) |. ( Always means since the seventies. ) I guess the reason is that a reliable computation of the modulus: | z | = ( | Re( z ) |^2 + | Im ( z ) |^2 )^(1/2) is complicated (see for example dlapy2 to do this operation without unneccessary overflows or underflows) and since it is complicate, it consumes time. There is a nice paragraph in Nick Higham's book "Accuracy and Stability of Numerical Algorithms", 2nd edition p.500, Sec 27.8. If you look at the original Level 1 BLAS paper from 1979 form Lawson, Hanson, Kincaid, and Krogh. ( available from Kincaid webpage http://www.cs.utexas.edu/users/kincaid/blas.pdf ) ( page 311) you would read some justification on this choice. So * a subroutine like ICAMAX would look like the largest element in absolute value with the definition: abs( z ) = | Re( z ) | + | Im ( z ) |. * a subroutine like ICAMAX does not compute the infinite norm of a complex vector. * a subroutine like ICASUM does not compute the 1-norm of a complex vector. Such routine do exist in the new BLAS standard. http://www.netlib.org/blas/blast-forum/chapter2.pdf page 19, table 2.1, under NORM. Anyway, you do not think "absolute value" is appropriate to reference: abs( z ) = | Re( z ) | + | Im ( z ) |. Fair enough. Suggestions? "taxi modulus"? One thing I have always wondered is whether GETRF which uses GETF2 which uses ICAMAX is more or less stable than one who would use | z | = ( | Re( z ) |^2 + | Im ( z ) |^2 )^(1/2) .... Cheers, Julien. On Dec 12, 2011, at 8:40 AM, Vitaly N. Golovach wrote: Dear LPACK development team, There is a mistake in the function SCABS1 in BLAS, see file BLAS/scabs1.f. The absolute value of a complex number is not the sum of the absolute values of its real and imaginary parts. Either the documentation is wrong or the code is wrong. The function SCABS1 is used only in BLAS/icamax.f. Actually, it is also used in BLAS/caxpy.f, but in a trivial way, where it cannot cause errors. Best, Vitaly ******************************* Vitaly N. Golovach LPMMC, Maison des Magist?res CNRS 25 avenue des Martyrs, BP166 38042 Grenoble Cedex, FRANCE Tel.: +33 4 76 88 79 82 Fax.: +33 4 76 88 79 83 Email: vitaly.n.golovach@Domain.Removed ******************************* REAL FUNCTION SCABS1(Z) * .. Scalar Arguments .. COMPLEX Z * .. * * Purpose * ======= * * SCABS1 computes absolute value of a complex number * * ===================================================================== * * .. Intrinsic Functions .. INTRINSIC ABS,AIMAG,REAL * .. SCABS1 = ABS(REAL(Z)) + ABS(AIMAG(Z)) RETURN END _______________________________________________ Lapack mailing list Lapack@Domain.Removed http://lists.eecs.utk.edu/mailman/listinfo/lapack -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.eecs.utk.edu/mailman/private/lapack/attachments/20111212/850ec803/attachment.html ```
 Current Thread [Lapack] mistake in BLAS/scabs1.f, Vitaly N. Golovach [Lapack] mistake in BLAS/scabs1.f, Langou, Julien <=

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