Add tests, documentation, and headers for lgamma().

This commit is contained in:
Stephen Heumann 2023-05-21 18:30:15 -05:00
parent c8517eff87
commit 661c9c440d
4 changed files with 39 additions and 0 deletions

View File

@ -150,6 +150,9 @@ int ilogbl(long double);
double ldexp(double, int);
float ldexpf(float, int);
long double ldexpl(long double, int);
double lgamma(double);
float lgammaf(float);
long double lgammal(long double);
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
long long llrint(double);
long long llrintf(float);

View File

@ -73,6 +73,7 @@
#define hypot(x,y) __tg_real_x_y(hypot,(x),(y))
#define ilogb(x) __tg_real_x(ilogb,(x))
#define ldexp(x,n) __tg_real_x_other(ldexp,(x),(n))
#define lgamma(x) __tg_real_x(lgamma,(x))
#define llrint(x) __tg_real_x(llrint,(x))
#define llround(x) __tg_real_x(llround,(x))
#define log(x) __tg_x(log,(x))

View File

@ -365,6 +365,34 @@ int main(void) {
expect_approx(erfcl(9.99L), 2.553157649309533e-45L);
expect_approx(erfcl(105.0L), 4.300838032791244e-4791L);
expect_exact(lgamma(1.0), +0.0);
expect_exact(lgammaf(2.0), -0.0);
expect_pole_error(lgammal(0.0), +INFINITY);
expect_pole_error(lgammal(-0.0), +INFINITY);
expect_pole_error(lgammal(-1.0), +INFINITY);
expect_pole_error(lgammal(-2.0), +INFINITY);
expect_pole_error(lgammal(-3.0), +INFINITY);
expect_pole_error(lgammal(-1e50), +INFINITY);
expect_pole_error(lgammal(-LDBL_MAX), +INFINITY);
expect_exact(lgamma(-INFINITY), +INFINITY);
expect_exact(lgammaf(+INFINITY), +INFINITY);
expect_approx(lgammal(1e-50L), 1.151292546497022842e+02L);
expect_approx(lgammal(0.5L), 5.723649429247000870e-01L);
expect_approx(lgammal(0.99L), 5.854806764709776173e-03L);
expect_approx(lgammal(1.00000000001L), -5.772156625868682203e-12L);
expect_approx(lgammal(1.25L), -9.827183642181316143e-02L);
expect_approx(lgammal(1.9999999999L), -4.227843352103923846e-11L);
expect_approx(lgammal(2.125L), 5.775985153034387160e-02L);
expect_approx(lgammal(3.5L), 1.200973602347074225e+00L);
expect_approx(lgammal(1200.75L), 7.310783651998328589e+03L);
expect_approx(lgammal(1e4928L), 1.134613933827465713e+4932L);
expect_approx(lgammal(-0.00000000001L), 2.532843602294027468e+01L);
expect_approx(lgammal(-0.99L), 4.609530213895523164e+00L);
expect_approx(lgammal(-1.5L), 8.600470153764810144e-01L);
expect_approx(lgammal(-2.000000953674316L), 1.316979555107021760e+01L);
expect_approx(lgammal(-5.75L), -4.624612415302172588e+00L);
expect_approx(lgammal(-1000000000000.5L), -2.663102111595595344e+13L);
expect_pole_error(tgamma(+0.0), +INFINITY);
expect_pole_error(tgammaf(-0.0), -INFINITY);
expect_domain_error(tgammal(-2.0));

View File

@ -1258,6 +1258,13 @@ int ilogbl(long double x);
These functions extract the binary exponent of x as an integer value, treating denormalized numbers as if they were normalized. If x is 0, infinite, or NaN, they return the macro values FP_ILOGB0, INT_MAX, or FP_ILOGBNAN, respectively.
#include <math.h>
double lgamma(double x);
float lgammaf(float x);
long double lgammal(long double x);
These functions compute the natural logarithm of the absolute value of the gamma function of x.
#include <math.h>
double log1p(double x);
float log1pf(float x);