This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch,Fortran] PR 33197 Add NORM2 and PARITY


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.


Cheers,
- Tobi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]