This is the mail archive of the
mailing list for the GCC project.
Re: [Patch,Fortran] PR 33197 Add NORM2 and PARITY
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: gcc patches f <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Thu, 26 Aug 2010 19:17:43 +0200
- Subject: Re: [Patch,Fortran] PR 33197 Add NORM2 and PARITY
- References: <4C766E7C.firstname.lastname@example.org>
On 2010-08-26 15:39, Tobias Burnus wrote:
For norm2 (L2 norm), one essentially does:
tmp = max(array) ! = L_infinity norm
norm2 = tmp * sqrt( (array/tmp)**2)
to avoid an overflow. However, it is implemented using a single pass.
For NORM2, an algorithm based on the one in BLAS is used though I have
realized that I start with SCALE == 1, RESULT = 0 while BLAS uses the
opposite starting values. Both seem to lead to the same result, thus, I
do not know which one is better. Quickly thinking about it, mine seems
to be better (faster + more accurate) for small values (<= 1.0), but I
might be wrong. Cf. http://www.netlib.org/blas/snrm2.f
Just a random idea: the maximum precision that such a single pass
algorithm can achieve is probably obtained by using and modifying the
binary exponent instead of multiplying with a scale factor as this
renders the scale transformations exact.