#
41e01628 |
| 29-Aug-2024 |
Steve Kargl <kargl@FreeBSD.org> |
Improve accuracy of asinf(3) and acosf(3)
This uses a better rational approximation to improve the accuracy of both functions. For exhaustive testing of asinf(3) in the interval, the current libm gi
Improve accuracy of asinf(3) and acosf(3)
This uses a better rational approximation to improve the accuracy of both functions. For exhaustive testing of asinf(3) in the interval, the current libm gives:
% ./tlibm asin -fPED -x 0x1p-12f -X 1 Interval tested for asinf: [0.000244141,1] ulp <= 0.5: 97.916% 98564994 | 97.916% 98564994 0.5 < ulp < 0.6: 2.038% 2051023 | 99.953% 100616017 0.6 < ulp < 0.7: 0.047% 47254 | 100.000% 100663271 0.7 < ulp < 0.8: 0.000% 25 | 100.000% 100663296 Max ulp: 0.729891 at 5.00732839e-01
which isn't too bad given that much of the computation is actually done in double floating point.
With the new rational approximation, exhaustive testing yields:
% ./tlibm asin -fPED -x 0x1p-12f -X 1 Interval tested for asinf: [0.000244141,1] ulp <= 0.5: 99.711% 100372643 | 99.711% 100372643 0.5 < ulp < 0.6: 0.288% 290357 | 100.000% 100663000 0.6 < ulp < 0.7: 0.000% 296 | 100.000% 100663296 Max ulp: 0.636344 at 5.09706438e-01
Similarly, for exhaustive testing of asinf(3) in the interval, the current libm gives:
% ./tlibm acos -fPED -x -1 -X -0x1p-12f Interval tested for acosf: [-1,-0.000244141] ulp <= 0.5: 97.008% 97651921 | 97.008% 97651921 0.5 < ulp < 0.6: 2.441% 2457242 | 99.450% 100109163 0.6 < ulp < 0.7: 0.472% 475503 | 99.922% 100584666 0.7 < ulp < 0.8: 0.071% 71309 | 99.993% 100655975 0.8 < ulp < 0.9: 0.007% 7319 | 100.000% 100663294 0.9 < ulp < 1.0: 0.000% 2 | 100.000% 100663296 Max ulp: 0.914007 at -5.01484931e-01
% ./tlibm acos -fPED -x 0x1p-12f -X 1 Interval tested for acosf: [0.000244141,1] ulp <= 0.5: 97.317% 97962530 | 97.317% 97962530 0.5 < ulp < 0.6: 2.340% 2355182 | 99.657% 100317712 0.6 < ulp < 0.7: 0.314% 316134 | 99.971% 100633846 0.7 < ulp < 0.8: 0.029% 29450 | 100.000% 100663296 Max ulp: 0.796035 at 4.99814630e-01
With the new rational approximation, exhaustive testing yields:
% ./tlibm acos -fPED -x -1 -X -0x1p-12f Interval tested for acosf: [-1,-0.000244141] ulp <= 0.5: 97.010% 97653245 | 97.010% 97653245 0.5 < ulp < 0.6: 2.442% 2458373 | 99.452% 100111618 0.6 < ulp < 0.7: 0.473% 476012 | 99.925% 100587630 0.7 < ulp < 0.8: 0.068% 68603 | 99.993% 100656233 0.8 < ulp < 0.9: 0.007% 7063 | 100.000% 100663296 Max ulp: 0.896189 at -5.04511118e-01
% ./tlibm acos -fPED -x 0x1p-12f -X 1 Interval tested for acosf: [0.000244141,1] ulp <= 0.5: 97.650% 98298175 | 97.650% 98298175 0.5 < ulp < 0.6: 2.028% 2041709 | 99.679% 100339884 0.6 < ulp < 0.7: 0.292% 293555 | 99.970% 100633439 0.7 < ulp < 0.8: 0.030% 29857 | 100.000% 100663296 Max ulp: 0.775875 at 4.91849005e-01
PR: 281001 MFC after: 1 week
show more ...
|
Revision tags: release/14.1.0, release/13.3.0 |
|
#
0dd5a560 |
| 28-Jan-2024 |
Steve Kargl <kargl@FreeBSD.org> |
lib/msun: Cleanup after $FreeBSD$ removal
Remove no longer needed explicit inclusion of sys/cdefs.h.
PR: 276669 MFC after: 1 week
|
Revision tags: release/14.0.0 |
|
#
1d386b48 |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
#
99843eb8 |
| 03-Aug-2023 |
Steve Kargl <kargl@FreeBSD.org> |
Clean up libm use of the __ieee754_ prefix
This removes the __ieee754_ prefix from a number of the math functions. msun/src/math_private.h contains the statement that
/* * ieee style elementar
Clean up libm use of the __ieee754_ prefix
This removes the __ieee754_ prefix from a number of the math functions. msun/src/math_private.h contains the statement that
/* * ieee style elementary functions * * We rename functions here to improve other sources' diffability * against fdlibm. */ #define __ieee754_sqrt sqrt ...
Here, fdlibm refers to https://netlib.org/fdlibm. It is seen from https://netlib.org/fdlibm/readme that this prefix was used to differentiate between different standards:
Wrapper functions will twist the result of the ieee754 function to comply to the standard specified by the value of _LIB_VERSION if _LIB_VERSION = _IEEE_, return the ieee754 result; if _LIB_VERSION = _SVID_, return SVID result; if _LIB_VERSION = _XOPEN_, return XOPEN result; if _LIB_VERSION = _POSIX_, return POSIX/ANSI result. (These are macros, see fdlibm.h for their definition.)
AFAICT, FreeBSD has never supported these wrappers. In addition, as C99, principally the long double, functions were added to libm, this convention was not maintained. Given that only 148 of 324 files under lib/msun contain a "Copyright (C) 1993 by Sun Microsystems" statement, the removal of the __ieee754_ prefix provides consistency across all source files.
The last time someone compared lib/msun to fdlibm appears to be
commit 3f70824172feb82ea3dcdb3866b54fe0eb7cd890 Author: David Schultz <das@FreeBSD.org> Date: Fri Feb 4 18:26:06 2005 +0000
Reduce diffs against vendor source (Sun fdlibm 5.3).
The most recent fdlibm RCS string that appears in a Sun Microsystem copyrighted file is date "95/01/18". With Oracle Corporation's acquisition of Sun Microsystems in 2009, it is unlikely that fdlibm will ever be updated. A search for fdlibm at https://opensource.oracle.com/ yields no hits.
Finally, OpenBSD removed the use of this prefix over 21 years ago. pSee revision 1.6 of OpenBSD's math_private.h.
Note: this does not drop the __ieee754_ prefix from the trigonometric argument reduction functions, e.g., __ieee754_rem_pio2. These functions are internal to the libm and exported through Symbol.map; and thus, reserved for the implementation.
PR: 272783 MFC after: 1 week
show more ...
|
Revision tags: release/13.2.0, release/12.4.0, release/13.1.0, release/12.3.0, release/13.0.0, release/12.2.0, release/11.4.0, release/12.1.0, release/11.3.0, release/12.0.0, release/11.2.0, release/10.4.0, release/11.1.0, release/11.0.1, release/11.0.0, release/10.3.0, release/10.2.0, release/10.1.0, release/9.3.0, release/10.0.0, release/9.2.0, release/8.4.0, release/9.1.0, release/8.3.0_cvs, release/8.3.0, release/9.0.0, release/7.4.0_cvs, release/8.2.0_cvs, release/7.4.0, release/8.2.0, release/8.1.0_cvs, release/8.1.0, release/7.3.0_cvs, release/7.3.0, release/8.0.0_cvs, release/8.0.0, release/7.2.0_cvs, release/7.2.0, release/7.1.0_cvs, release/7.1.0, release/6.4.0_cvs, release/6.4.0 |
|
#
e0345583 |
| 03-Aug-2008 |
David Schultz <das@FreeBSD.org> |
Minor improvements: - Improve the order of some tests. - Fix style.
Submitted by: bde
|
#
8862f666 |
| 01-Aug-2008 |
David Schultz <das@FreeBSD.org> |
Fix some problems with asinf(), acosf(), atanf(), and atan2f():
- Adjust several constants for float precision. Some thresholds that were appropriate for double precision were never changed when
Fix some problems with asinf(), acosf(), atanf(), and atan2f():
- Adjust several constants for float precision. Some thresholds that were appropriate for double precision were never changed when these routines were converted to float precision. This has an impact on performance but not accuracy. (Submitted by bde.)
- Reduce the degrees of the polynomials used. A smaller degree suffices for float precision.
- In asinf(), use double arithmetic in part of the calculation to avoid a corner case and some complicated arithmetic involving a division and some buggy constants. This improves performance and accuracy.
Max error (ulps): asinf acosf atanf before 0.925 0.782 0.852 after 0.743 0.804 0.852
As bde points out, it's cheaper for asin*() and acos*() to use polynomials instead of rational functions, but that's a task for another day.
show more ...
|
#
16608a81 |
| 31-Jul-2008 |
David Schultz <das@FreeBSD.org> |
As in other parts of libm, mark a few constants as volatile to prevent spurious optimizations. gcc doesn't support FENV_ACCESS, so when it folds constants, it assumes that the rounding mode is always
As in other parts of libm, mark a few constants as volatile to prevent spurious optimizations. gcc doesn't support FENV_ACCESS, so when it folds constants, it assumes that the rounding mode is always the default and floating point exceptions never matter.
show more ...
|
Revision tags: release/7.0.0_cvs, release/7.0.0 |
|
#
5aa554c7 |
| 22-Feb-2008 |
David Schultz <das@FreeBSD.org> |
s/rcsid/__FBSDID/
|
Revision tags: release/6.3.0_cvs, release/6.3.0, release/6.2.0_cvs, release/6.2.0, release/5.5.0_cvs, release/5.5.0, release/6.1.0_cvs, release/6.1.0, release/6.0.0_cvs, release/6.0.0, release/5.4.0_cvs, release/5.4.0, release/4.11.0_cvs, release/4.11.0, release/5.3.0_cvs, release/5.3.0, release/4.10.0_cvs, release/4.10.0, release/5.2.1_cvs, release/5.2.1, release/5.2.0_cvs, release/5.2.0, release/4.9.0_cvs, release/4.9.0, release/5.1.0_cvs, release/5.1.0, release/4.8.0_cvs, release/4.8.0, release/5.0.0_cvs, release/5.0.0, release/4.7.0_cvs, release/4.6.2_cvs, release/4.6.2, release/4.6.1, release/4.6.0_cvs |
|
#
a82bbc73 |
| 28-May-2002 |
Alfred Perlstein <alfred@FreeBSD.org> |
Assume __STDC__, remove non-__STDC__ code.
Submitted by: keramida
|
Revision tags: release/4.5.0_cvs, release/4.4.0_cvs, release/4.3.0_cvs, release/4.3.0, release/4.2.0, release/4.1.1_cvs, release/4.1.0, release/3.5.0_cvs, release/4.0.0_cvs, release/3.4.0_cvs, release/3.3.0_cvs |
|
#
7f3dea24 |
| 28-Aug-1999 |
Peter Wemm <peter@FreeBSD.org> |
$Id$ -> $FreeBSD$
|
Revision tags: release/3.2.0, release/3.1.0, release/3.0.0, release/2.2.8, release/2.2.7, release/2.2.6, release/2.2.5_cvs, release/2.2.2_cvs, release/2.2.1_cvs, release/2.2.0, release/2.1.7_cvs |
|
#
9faa8dc6 |
| 09-Mar-1997 |
Bruce Evans <bde@FreeBSD.org> |
Use __ieee754_sqrt() instead of sqrt() internally. Similarly for the float versions. Using sqrt() was inefficient.
Obtained from: NetBSD
|
#
7e546392 |
| 22-Feb-1997 |
Peter Wemm <peter@FreeBSD.org> |
Revert $FreeBSD$ to $Id$
|
Revision tags: release/2.1.6_cvs, release/2.1.6.1 |
|
#
1130b656 |
| 14-Jan-1997 |
Jordan K. Hubbard <jkh@FreeBSD.org> |
Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so
Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long.
Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
show more ...
|
Revision tags: release/2.1.5_cvs, release/2.1.0_cvs, release/2.0.5_cvs |
|
#
6c06b4e2 |
| 30-May-1995 |
Rodney W. Grimes <rgrimes@FreeBSD.org> |
Remove trailing whitespace.
|
Revision tags: release/2.0 |
|
#
3a8617a8 |
| 19-Aug-1994 |
Jordan K. Hubbard <jkh@FreeBSD.org> |
J.T. Conklin's latest version of the Sun math library.
-- Begin comments from J.T. Conklin: The most significant improvement is the addition of "float" versions of the math functions that take float
J.T. Conklin's latest version of the Sun math library.
-- Begin comments from J.T. Conklin: The most significant improvement is the addition of "float" versions of the math functions that take float arguments, return floats, and do all operations in floating point. This doesn't help (performance) much on the i386, but they are still nice to have.
The float versions were orginally done by Cygnus' Ian Taylor when fdlibm was integrated into the libm we support for embedded systems. I gave Ian a copy of my libm as a starting point since I had already fixed a lot of bugs & problems in Sun's original code. After he was done, I cleaned it up a bit and integrated the changes back into my libm. -- End comments
Reviewed by: jkh Submitted by: jtc
show more ...
|
Revision tags: release/13.2.0, release/12.4.0, release/13.1.0, release/12.3.0, release/13.0.0, release/12.2.0, release/11.4.0, release/12.1.0, release/11.3.0, release/12.0.0, release/11.2.0, release/10.4.0, release/11.1.0, release/11.0.1, release/11.0.0, release/10.3.0, release/10.2.0, release/10.1.0, release/9.3.0, release/10.0.0, release/9.2.0, release/8.4.0, release/9.1.0, release/8.3.0_cvs, release/8.3.0, release/9.0.0, release/7.4.0_cvs, release/8.2.0_cvs, release/7.4.0, release/8.2.0, release/8.1.0_cvs, release/8.1.0, release/7.3.0_cvs, release/7.3.0, release/8.0.0_cvs, release/8.0.0, release/7.2.0_cvs, release/7.2.0, release/7.1.0_cvs, release/7.1.0, release/6.4.0_cvs, release/6.4.0 |
|
#
e0345583 |
| 03-Aug-2008 |
David Schultz <das@FreeBSD.org> |
Minor improvements: - Improve the order of some tests. - Fix style.
Submitted by: bde
|
#
8862f666 |
| 01-Aug-2008 |
David Schultz <das@FreeBSD.org> |
Fix some problems with asinf(), acosf(), atanf(), and atan2f():
- Adjust several constants for float precision. Some thresholds that were appropriate for double precision were never changed when
Fix some problems with asinf(), acosf(), atanf(), and atan2f():
- Adjust several constants for float precision. Some thresholds that were appropriate for double precision were never changed when these routines were converted to float precision. This has an impact on performance but not accuracy. (Submitted by bde.)
- Reduce the degrees of the polynomials used. A smaller degree suffices for float precision.
- In asinf(), use double arithmetic in part of the calculation to avoid a corner case and some complicated arithmetic involving a division and some buggy constants. This improves performance and accuracy.
Max error (ulps): asinf acosf atanf before 0.925 0.782 0.852 after 0.743 0.804 0.852
As bde points out, it's cheaper for asin*() and acos*() to use polynomials instead of rational functions, but that's a task for another day.
show more ...
|
#
16608a81 |
| 31-Jul-2008 |
David Schultz <das@FreeBSD.org> |
As in other parts of libm, mark a few constants as volatile to prevent spurious optimizations. gcc doesn't support FENV_ACCESS, so when it folds constants, it assumes that the rounding mode is always
As in other parts of libm, mark a few constants as volatile to prevent spurious optimizations. gcc doesn't support FENV_ACCESS, so when it folds constants, it assumes that the rounding mode is always the default and floating point exceptions never matter.
show more ...
|
Revision tags: release/7.0.0_cvs, release/7.0.0 |
|
#
5aa554c7 |
| 22-Feb-2008 |
David Schultz <das@FreeBSD.org> |
s/rcsid/__FBSDID/
|
Revision tags: release/6.3.0_cvs, release/6.3.0, release/6.2.0_cvs, release/6.2.0, release/5.5.0_cvs, release/5.5.0, release/6.1.0_cvs, release/6.1.0, release/6.0.0_cvs, release/6.0.0, release/5.4.0_cvs, release/5.4.0, release/4.11.0_cvs, release/4.11.0, release/5.3.0_cvs, release/5.3.0, release/4.10.0_cvs, release/4.10.0, release/5.2.1_cvs, release/5.2.1, release/5.2.0_cvs, release/5.2.0, release/4.9.0_cvs, release/4.9.0, release/5.1.0_cvs, release/5.1.0, release/4.8.0_cvs, release/4.8.0, release/5.0.0_cvs, release/5.0.0, release/4.7.0_cvs, release/4.6.2_cvs, release/4.6.2, release/4.6.1, release/4.6.0_cvs |
|
#
a82bbc73 |
| 28-May-2002 |
Alfred Perlstein <alfred@FreeBSD.org> |
Assume __STDC__, remove non-__STDC__ code.
Submitted by: keramida
|
Revision tags: release/4.5.0_cvs, release/4.4.0_cvs, release/4.3.0_cvs, release/4.3.0, release/4.2.0, release/4.1.1_cvs, release/4.1.0, release/3.5.0_cvs, release/4.0.0_cvs, release/3.4.0_cvs, release/3.3.0_cvs |
|
#
7f3dea24 |
| 28-Aug-1999 |
Peter Wemm <peter@FreeBSD.org> |
$Id$ -> $FreeBSD$
|
Revision tags: release/3.2.0, release/3.1.0, release/3.0.0, release/2.2.8, release/2.2.7, release/2.2.6, release/2.2.5_cvs, release/2.2.2_cvs, release/2.2.1_cvs, release/2.2.0, release/2.1.7_cvs |
|
#
9faa8dc6 |
| 09-Mar-1997 |
Bruce Evans <bde@FreeBSD.org> |
Use __ieee754_sqrt() instead of sqrt() internally. Similarly for the float versions. Using sqrt() was inefficient.
Obtained from: NetBSD
|
#
7e546392 |
| 22-Feb-1997 |
Peter Wemm <peter@FreeBSD.org> |
Revert $FreeBSD$ to $Id$
|
Revision tags: release/2.1.6_cvs, release/2.1.6.1 |
|
#
1130b656 |
| 14-Jan-1997 |
Jordan K. Hubbard <jkh@FreeBSD.org> |
Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so
Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long.
Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
show more ...
|
Revision tags: release/2.1.5_cvs, release/2.1.0_cvs, release/2.0.5_cvs |
|
#
6c06b4e2 |
| 30-May-1995 |
Rodney W. Grimes <rgrimes@FreeBSD.org> |
Remove trailing whitespace.
|