This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: this seems to lost (complex norm, abs)
- To: Theodore Papadopoulo <Theodore dot Papadopoulo at sophia dot inria dot fr>
- Subject: Re: this seems to lost (complex norm, abs)
- From: Levente Farkas <lfarkas at mindmaker dot hu>
- Date: Thu, 20 Sep 2001 18:08:30 +0200
- Cc: STDC++ <libstdc++ at sources dot redhat dot com>
- Organization: Mindmaker Ltd.
- References: <200109201256.f8KCuuJ29476@mururoa.inria.fr>
- Reply-To: lfarkas at mindmaker dot hu
Theodore Papadopoulo wrote:
>
> lfarkas@mindmaker.hu said:
> > it contains 2 abs, 2 addition, 2 division, 3 multilication and 1 sqrt
> > may be a few cosine and tan help a bit more:-) while the trivial
> > "grammar school implementation": sqrt(norm(__z))
> > contains 1 addition, 2 multilication, 1 sqrt
> > so why we use it? may be in case of __z == 0 it's faster a bit, so an
>
> This is done to avoid overflow. Take eg, x = sqrt(DOUBLE_MAX)+epsilon
> and y=0, your formula will overflow (yelding +Infinity) while the used formula
> will give the proper result.
hmm, it seems I forget my numerical experiences. but the original
problem with norm still apply (there cant be overflow and will be much
faster).
-- Levente "Si vis pacem para bellum!"