This is the mail archive of the
mailing list for the GCC project.
Re: definition of complex norm
- To: <boost at yahoogroups dot com>, <nbecker at fred dot net>
- Subject: Re: definition of complex norm
- From: "Tim Prince" <tprince at computer dot org>
- Date: Thu, 1 Nov 2001 06:05:51 -0800
- Cc: <gcc at gcc dot gnu dot org>
- References: <email@example.com>
----- Original Message -----
Sent: Thursday, November 01, 2001 5:34 AM
Subject: definition of complex norm
> In the current gcc, norm of complex is defined in terms of abs. I
> believe the definition should be changed to:
> norm(z) = sqr(real(z)) + sqr (imag (z))
> My reasons are:
> 1. More efficient
> 2. Works for complex<int> (important in DSP)
> 3. Possibly more accurate
> I have started a discussion on firstname.lastname@example.org on this subject. I'm
> wondering if any of you have an opinion.
If this is a library issue, there won't be much patience with it on this
list. Even commonly used functions required by C89 are left to the
I suppose that the usual strategy (not followed by glibc with -O and -O2)
is to supply an implementation which doesn't break with boundary values,
and leave it up to the programmer to plug in her own version, if better
speed or accuracy is wanted.
Since complex absolute value requires your function, it is a fairly
widespread issue, well known over the years, and influential in the
design of the x87 and 68xxx processors which provide means of avoiding
over/underflow on double boundary values. gcc doesn't like to go into
this much processor-dependent detail.