Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance

From: Darafei "Komяpa" Praliaskouski <me(at)komzpa(dot)net>
To: Lætitia Avrot <laetitia(dot)avrot(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance
Date: 2019-03-19 05:49:44
Message-ID: CAC8Q8tLEC0YyQd+E8c25W0HcqwGz+K_P7A5w1xxFpHjZ71zSSA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I really appreciate the addition of tanh into core postgres.

If someone doubts it is useful: it is used as a part of math in
geographical calculations.

Say you have your cars in planar Mercator projection and want to move them
"1 second forward by this heading with this speed". sin/cos and the
distance on X/Y, but the distance must be scaled properly - and that
scaling coefficient is cosd(latitude), which you don't have directly - you
have it in projected meters. If you don't want to fire up full-featured
PostGIS on this hot path you inline all formulas together, result is nice
and small - but has tanh in it, which I was surprised to find only in
Oracle Compatibility extensions. Pure sql tanh was good enough, but gave me
disturbance :)

Here's the code:
https://github.com/gojuno/lostgis/blob/master/sql/functions/coslat.sql#L21

On Wed, Mar 13, 2019 at 5:34 PM Lætitia Avrot <laetitia(dot)avrot(at)gmail(dot)com>
wrote:

> Thanks, Tom !
>
> Thank you everyone for your help and patience.
>
> Cheers,
>
> Lætitia
>
> Le mar. 12 mars 2019 à 20:57, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> a écrit :
>
>> =?UTF-8?Q?L=C3=A6titia_Avrot?= <laetitia(dot)avrot(at)gmail(dot)com> writes:
>> > So, as you're asking that too, maybe my reasons weren't good enough.
>> You'll
>> > find enclosed a new version of the patch
>> > with asinh, acosh and atanh (v5).
>>
>> Pushed with some minor adjustments (mainly cleanup of the error handling).
>>
>> > Then I tried for several days to implement the 6 last hyperbolic
>> functions,
>> > but I wasn't satisfied with the result, so I just dropped it.
>>
>> Yeah, I agree that sech() and so on are not worth the trouble. If they
>> were commonly used, they'd be in POSIX ...
>>
>> regards, tom lane
>>
>

--
Darafei Praliaskouski
Support me: http://patreon.com/komzpa

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Paul Guo 2019-03-19 06:09:03 Two pg_rewind patches (auto generate recovery conf and ensure clean shutdown)
Previous Message pavan gudivada 2019-03-19 05:46:30 Re: GSOC Application