musl/src/math/logl.c, branch master musl - an implementation of the standard library for Linux-based systems math: add dummy implementations of 128 bit long double functions 2015年03月11日T22:54:53+00:00 Szabolcs Nagy nsz@port70.net 2015年03月10日T20:01:20+00:00 f4e4632abfa8297db1485e132bb15b9ef6c32a1b This is in preparation for the aarch64 port only to have the long double math symbols available on ld128 platforms. The implementations should be fixed up later once we have proper tests for these functions. Added bigendian handling for ld128 bit manipulations too.
This is in preparation for the aarch64 port only to have the long
double math symbols available on ld128 platforms. The implementations
should be fixed up later once we have proper tests for these functions.
Added bigendian handling for ld128 bit manipulations too.
math: extensive log*.c cleanup 2013年10月28日T01:16:14+00:00 Szabolcs Nagy nsz@port70.net 2013年10月28日T01:16:14+00:00 71d23b310383699a3101ea8bf088398796529ddd The log, log2 and log10 functions share a lot of code and to a lesser extent log1p too. A small part of the code was kept separately in __log1p.h, but since it did not capture much of the common code and it was inlined anyway, it did not solve the issue properly. Now the log functions have significant code duplication, which may be resolved later, until then they need to be modified together. logl, log10l, log2l, log1pl: * Fix the sign when the return value should be -inf. * Remove the volatile hack from log10l (seems unnecessary) log1p, log1pf: * Change the handling of small inputs: only |x|<2^-53 is special (then it is enough to return x with the usual subnormal handling) this fixes the sign of log1p(0) in downward rounding. * Do not handle the k==0 case specially (other than skipping the elaborate argument reduction) * Do not handle 1+x close to power-of-two specially (this code was used rarely, did not give much speed up and the precision wasn't better than the general) * Fix the correction term formula (c=1-(u-x) was used incorrectly when x<1 but (double)(x+1)==2, this was not a critical issue) * Use the exact same method for calculating log(1+f) as in log (except in log1p the c correction term is added to the result). log, logf, log10, log10f, log2, log2f: * Use double_t and float_t consistently. * Now the first part of log10 and log2 is identical to log (until the return statement, hopefully this makes maintainence easier). * Most special case formulas were removed (close to power-of-two and k==0 cases), they increase the code size without providing precision or performance benefits (and obfuscate the code). Only x==1 is handled specially so in downward rounding mode the sign of zero is correct (the general formula happens to give -0). * For x==0 instead of -1/0.0 or -two54/0.0, return -1/(x*x) to force raising the exception at runtime. * Arg reduction code is changed (slightly simplified) * The thresholds for arg reduction to [sqrt(2)/2,sqrt(2)] are now consistently the [0x3fe6a09e00000000,0x3ff6a09dffffffff] and the [0x3f3504f3,0x3fb504f2] intervals for double and float reductions respectively (the exact threshold values are not critical) * Remove the obsolete comment for the FLT_EVAL_METHOD!=0 case in log2f (The same code is used for all eval methods now, on i386 slightly simpler code could be used, but we have asm there anyway) all: * Fix signed int arithmetics (using unsigned for bitmanipulation) * Fix various comments
The log, log2 and log10 functions share a lot of code and to a lesser
extent log1p too. A small part of the code was kept separately in
__log1p.h, but since it did not capture much of the common code and
it was inlined anyway, it did not solve the issue properly. Now the
log functions have significant code duplication, which may be resolved
later, until then they need to be modified together.
logl, log10l, log2l, log1pl:
* Fix the sign when the return value should be -inf.
* Remove the volatile hack from log10l (seems unnecessary)
log1p, log1pf:
* Change the handling of small inputs: only |x|<2^-53 is special
 (then it is enough to return x with the usual subnormal handling)
 this fixes the sign of log1p(0) in downward rounding.
* Do not handle the k==0 case specially (other than skipping the
 elaborate argument reduction)
* Do not handle 1+x close to power-of-two specially (this code was
 used rarely, did not give much speed up and the precision wasn't
 better than the general)
* Fix the correction term formula (c=1-(u-x) was used incorrectly
 when x<1 but (double)(x+1)==2, this was not a critical issue)
* Use the exact same method for calculating log(1+f) as in log
 (except in log1p the c correction term is added to the result).
log, logf, log10, log10f, log2, log2f:
* Use double_t and float_t consistently.
* Now the first part of log10 and log2 is identical to log (until the
 return statement, hopefully this makes maintainence easier).
* Most special case formulas were removed (close to power-of-two and
 k==0 cases), they increase the code size without providing precision
 or performance benefits (and obfuscate the code).
 Only x==1 is handled specially so in downward rounding mode the
 sign of zero is correct (the general formula happens to give -0).
* For x==0 instead of -1/0.0 or -two54/0.0, return -1/(x*x) to force
 raising the exception at runtime.
* Arg reduction code is changed (slightly simplified)
* The thresholds for arg reduction to [sqrt(2)/2,sqrt(2)] are now
 consistently the [0x3fe6a09e00000000,0x3ff6a09dffffffff] and the
 [0x3f3504f3,0x3fb504f2] intervals for double and float reductions
 respectively (the exact threshold values are not critical)
* Remove the obsolete comment for the FLT_EVAL_METHOD!=0 case in log2f
 (The same code is used for all eval methods now, on i386 slightly
 simpler code could be used, but we have asm there anyway)
all:
* Fix signed int arithmetics (using unsigned for bitmanipulation)
* Fix various comments
math: raise flags in logl.c on <= 0 arguments 2012年11月12日T23:49:55+00:00 Szabolcs Nagy nsz@port70.net 2012年11月12日T23:49:55+00:00 e2fe959fe2a450f74271d4d3c4b0d9456f889125
use scalbn or *2.0 instead of ldexp, fix fmal 2012年03月19日T21:57:58+00:00 nsz nsz@port70.net 2012年03月19日T21:57:58+00:00 2786c7d21611b9fa3b2fe356542cf213e7dd0ba4 Some code assumed ldexp(x, 1) is faster than 2.0*x, but ldexp is a wrapper around scalbn which uses multiplications inside, so this optimization is wrong. This commit also fixes fmal which accidentally used ldexp instead of ldexpl loosing precision. There are various additional changes from the work-in-progress const cleanups.
Some code assumed ldexp(x, 1) is faster than 2.0*x,
but ldexp is a wrapper around scalbn which uses
multiplications inside, so this optimization is
wrong.
This commit also fixes fmal which accidentally
used ldexp instead of ldexpl loosing precision.
There are various additional changes from the
work-in-progress const cleanups.
fix loads of missing const in new libm, and some global vars (?!) in powl 2012年03月18日T05:58:28+00:00 Rich Felker dalias@aerifal.cx 2012年03月18日T05:58:28+00:00 9e2a895aaaa4a3985e94ae4f3e24c1af65f9bb34
first commit of the new libm! 2012年03月13日T05:17:53+00:00 Rich Felker dalias@aerifal.cx 2012年03月13日T05:17:53+00:00 b69f695acedd4ce2798ef9ea28d834ceccc789bd thanks to the hard work of Szabolcs Nagy (nsz), identifying the best (from correctness and license standpoint) implementations from freebsd and openbsd and cleaning them up! musl should now fully support c99 float and long double math functions, and has near-complete complex math support. tgmath should also work (fully on gcc-compatible compilers, and mostly on any c99 compiler). based largely on commit 0376d44a890fea261506f1fc63833e7a686dca19 from nsz's libm git repo, with some additions (dummy versions of a few missing long double complex functions, etc.) by me. various cleanups still need to be made, including re-adding (if they're correct) some asm functions that were dropped.
thanks to the hard work of Szabolcs Nagy (nsz), identifying the best
(from correctness and license standpoint) implementations from freebsd
and openbsd and cleaning them up! musl should now fully support c99
float and long double math functions, and has near-complete complex
math support. tgmath should also work (fully on gcc-compatible
compilers, and mostly on any c99 compiler).
based largely on commit 0376d44a890fea261506f1fc63833e7a686dca19 from
nsz's libm git repo, with some additions (dummy versions of a few
missing long double complex functions, etc.) by me.
various cleanups still need to be made, including re-adding (if
they're correct) some asm functions that were dropped.

AltStyle によって変換されたページ (->オリジナル) /