1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Add support for gamma() and lgamma() functions.

These are useful general-purpose math functions which are included in
POSIX and C99, and are commonly included in other math libraries, so
expose them as SQL-callable functions.

Author: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Stepan Neretin <sncfmgg@gmail.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Dmitry Koval <d.koval@postgrespro.ru>
Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com>
Discussion: https://postgr.es/m/CAEZATCXpGyfjXCirFk9au+FvM0y2Ah+2-0WSJx7MO368ysNUPA@mail.gmail.com
This commit is contained in:
Dean Rasheed
2025-03-26 09:35:53 +00:00
parent 7c82b4f711
commit a3b6dfd410
6 changed files with 214 additions and 1 deletions

View File

@ -1396,6 +1396,27 @@ SELECT NOT(ROW(table.*) IS NOT NULL) FROM TABLE; -- detect at least one null in
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm>
<primary>gamma</primary>
</indexterm>
<function>gamma</function> ( <type>double precision</type> )
<returnvalue>double precision</returnvalue>
</para>
<para>
Gamma function
</para>
<para>
<literal>gamma(0.5)</literal>
<returnvalue>1.772453850905516</returnvalue>
</para>
<para>
<literal>gamma(6)</literal>
<returnvalue>120</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm>
@ -1436,6 +1457,23 @@ SELECT NOT(ROW(table.*) IS NOT NULL) FROM TABLE; -- detect at least one null in
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm>
<primary>lgamma</primary>
</indexterm>
<function>lgamma</function> ( <type>double precision</type> )
<returnvalue>double precision</returnvalue>
</para>
<para>
Natural logarithm of the absolute value of the gamma function
</para>
<para>
<literal>lgamma(1000)</literal>
<returnvalue>5905.220423209181</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm>