From: | "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> |
---|---|
To: | "Paul Matthews" <plm(at)netspace(dot)net(dot)au> |
Cc: | "David Fetter" <david(at)fetter(dot)org>,<pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Slaying the HYPOTamus |
Date: | 2009-08-24 17:47:42 |
Message-ID: | 4A928BEE0200002500029FF2@gw.wicourts.gov |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
David Fetter <david(at)fetter(dot)org> wrote:
> On Mon, Aug 24, 2009 at 11:14:19PM +1000, Paul Matthews wrote:
> These next two lines are a teensy bit baroque. Is there some
> significant speed increase that would justify them?
>
>> if (x == 0.0)
>> return 0.0;
>> else {
>> yx = y/x;
>> return x*sqrt(1.0+yx*yx);
>> }
>> }
I think the reason is overflow. From the function comment:
>> * The traditional formulae of x^2+y^2 is rearranged
>> * to bring x outside the sqrt. This allows computation of the
hypotenuse
>> * for much larger magnitudes than otherwise normally possible.
Although I don't see why the first part isn't:
if (y == 0.0)
return x;
-Kevin
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2009-08-24 17:48:37 | Re: 8.5 release timetable, again |
Previous Message | Tom Lane | 2009-08-24 17:41:28 | Re: DELETE syntax on JOINS |