Page MenuHomeFreeBSD

Improve accuracy and range of tgamma*(3)

Authored by markm on Dec 14 2021, 6:02 PM.
Referenced Files
Unknown Object (File)
Wed, May 22, 3:05 AM
Unknown Object (File)
Sun, May 19, 3:05 AM
Unknown Object (File)
Fri, May 17, 3:10 AM
Unknown Object (File)
Wed, May 15, 5:49 PM
Unknown Object (File)
Mon, May 13, 4:13 AM
Unknown Object (File)
Thu, May 2, 10:45 PM
Unknown Object (File)
Apr 25 2024, 8:25 AM
Unknown Object (File)
Jan 29 2024, 11:44 PM


  • lib/msun/bsdsrc/b_exp.c: . Replace scalb() usage with C99's ldexp(). . Replace finite(x) usage with C99's isfinite(). . Whitespace changes towards style(9). . Remove include of "mathimpl.h". It is no longer needed. . Remove #if 0 ... #endif code, which has been present since svn r93211 (2002-03-26). . New minimax polynomial coefficients. . Add comments to explain origins of some constants. . Use ansi-C prototype. Remove K&R prototype. Add static to prototype.
  • lib/msun/bsdsrc/b_log.c: . Remove include of "mathimpl.h". It is no longer needed. . Fix comments to actually describe the code. . Reduce minimax polynomial from degree 4 to degree 3. This uses newly computed coefficients. . Use ansi-C prototype. Remove K&R prototype. Add static to prototype. . Remove volatile in declaration of u1. . Alphabetize decalaration list. . Whitespace changes towards style(9). . In argument reduction of x to g and m, replace use of logb() and ldexp() with a single call to frexp(). Add code to get 1 <= g < 2. . Remove #if 0 ... #endif code, which has been present since svn r93211 (2002-03-26). . The special case m == -1022, replace logb() with ilogb().
  • lib/msun/bsdsrc/b_tgamma.c: . Update comments. Fix comments where needed. . Add float.h to get LDBL_MANT_DIG for weak reference of tgammal to tgamma. . Remove include of "mathimpl.h". It is no longer needed. . Use "math.h" instead of <math.h>. . Add '#include math_private.h" . Add struct Double from mathimpl.h and include b_log.c and b_exp.c. . Remove forward declarations of neg_gam(), small_gam(), smaller_gam, large_gam() and ratfun_gam() by re-arranging the code to move these function above their first reference. . New minimax coefficients for polynomial in large_gam(). . New splitting of a0 into a0hi nd a0lo, which include additional bits of precision. . Use ansi-C prototype. Remove K&R prototype. . Replace the TRUNC() macro with a simple cast of a double entities to float before assignment (functional changes). . Replace sin(M_PI*z) with sinpi(z) and cos(M_PI*(0.5-z)) with cospi(0.5-z).

Submitted-by: Steve Kargl

  • lib/msun/Makefile b/lib/msun/Makefile: . Disconnect imprecise.c from the build. This file can be deleted. . Add b_tgammal.c to the build for ld80 and ld128 targets. The ld128 is a 'git mv' of imprecise.c to ld128/b_tgammal.c.
  • lib/msun/ld80/b_expl.c: . New file. Implement expD for ld80 targets. This is based on bsdsrc/b_exp.c.
  • lib/msun/ld80/b_logl.c: . New file. Implement logD for ld80 targets. This is based on bsdsrc/b_log.c.
  • lib/msun/ld80/b_tgammal.c b/lib/msun/ld80/b_tgammal.c . New file. Implement tgammal(x) for ld80 targets.

Submitted-By: Steve Kargl

Diff Detail

rG FreeBSD src repository
Lint Not Applicable
Tests Not Applicable

Event Timeline

markm requested review of this revision.Dec 14 2021, 6:02 PM

This is two git commits - see the commit message.

markm retitled this revision from * lib/msun/Makefile: . Disconnect b_exp.c and b_log.c from the build. to Improve accuracy and range of tgamma*(3).Dec 14 2021, 6:07 PM

the structural parts of this are good. I'm not enough of a numeric computation person to know if the math is still good (or improved), though it looks like it should be.

I missed the move of imprecise.c to its new, temporary home in ld128.

pfg added a subscriber: pfg.

I appreciate this effort going on. Getting good implementations of these functions is tough.,

For the record: I once tried to replace the OpenOffice implementations of the gamma functions with Boost and the results were so different that all tests failed.

This revision is now accepted and ready to land.Dec 15 2021, 1:48 AM
This revision was automatically updated to reflect the committed changes.