summaryrefslogtreecommitdiff
path: root/src/math
AgeCommit message (Collapse)AuthorFilesLines
2012-12-16math: move x86_64 exp2l implementation to exp2l.s from expl.sSzabolcs Nagy3-85/+76
2012-12-14math: fix i386/expl.s with more precise x*log2eSzabolcs Nagy2-7/+107
with naive exp2l(x*log2e) the last 12bits of the result was incorrect for x with large absolute value with hi + lo = x*log2e is caluclated to 128 bits precision and then expl(x) = exp2l(hi) + exp2l(hi) * f2xm1(lo) this gives <1.5ulp measured error everywhere in nearest rounding mode
2012-12-12math: add a non-dummy tgamma implementationSzabolcs Nagy2-20/+215
uses the lanczos approximation method with the usual tweaks. same parameters were selected as in boost and python. (avoides some extra work and special casing found in boost so the precision is not that good: measured error is <5ulp for positive x and <10ulp for negative) an alternative lgamma_r implementation is also given in the same file which is simpler and smaller than the current one, but less precise so it's ifdefed out for now.
2012-12-12math: cosh cleanupSzabolcs Nagy3-70/+63
do fabs by hand, don't check for nan and inf separately
2012-12-12math: fix comment in __rem_pio2f.cSzabolcs Nagy1-2/+2
2012-12-12math: add empty __invtrigl.s to i386 and x86_64Szabolcs Nagy2-0/+0
__invtrigl is not needed when acosl, asinl, atanl have asm implementations
2012-12-11math: clean up inverse trigonometric functionsSzabolcs Nagy12-377/+258
modifications: * avoid unsigned->signed conversions * removed various volatile hacks * use FORCE_EVAL when evaluating only for side-effects * factor out R() rational approximation instead of manual inline * __invtrigl.h now only provides __invtrigl_R, __pio2_hi and __pio2_lo * use 2*pio2_hi, 2*pio2_lo instead of pi_hi, pi_lo otherwise the logic is not changed, long double versions will need a revisit when a genaral long double cleanup happens
2012-12-11math: rewrite inverse hyperbolic functions to be simpler/smallerSzabolcs Nagy9-406/+149
modifications: * avoid unsigned->signed integer conversion * do not handle special cases when they work correctly anyway * more strict threshold values (0x1p26 instead of 0x1p28 etc) * smaller code, cleaner branching logic * same precision as the old code: acosh(x) has up to 2ulp error in [1,1.125] asinh(x) has up to 1.6ulp error in [0.125,0.5], [-0.5,-0.125] atanh(x) has up to 1.7ulp error in [0.125,0.5], [-0.5,-0.125]
2012-12-07fix trailing whitespace issues that crept in here and thereRich Felker1-1/+1
2012-11-18math: use float constants in exp10f.cSzabolcs Nagy1-1/+1
use the 'f' suffix when a float constant is not representable
2012-11-18math: expl.c cleanupSzabolcs Nagy1-24/+19
raise overflow and underflow when necessary, fix various comments.
2012-11-18math: expf.c cleanupSzabolcs Nagy2-63/+55
similar to exp.c cleanup: use scalbnf, don't return excess precision, drop some optimizatoins. exp.c was changed to be more consistent with expf.c code.
2012-11-17math: cleanup exp2.c exp2f.c and exp2l.cSzabolcs Nagy3-86/+56
* old code relied on sign extension on right shift * exp2l ld64 wrapper was wrong * use scalbn instead of bithacks
2012-11-17math: exp.c clean upSzabolcs Nagy1-72/+49
overflow and underflow was incorrect when the result was not stored. an optimization for the 0.5*ln2 < |x| < 1.5*ln2 domain was removed. did various cleanups around static constants and made the comments consistent with the code.
2012-11-14math: ld80 invtrig cleanupsSzabolcs Nagy8-110/+87
keeping only commonly used data in invtrigl
2012-11-13math: simplify hypot and hypotf using scalbnSzabolcs Nagy2-11/+4
this also fixes overflow/underflow raising and excess precision issues (as those are handled well in scalbn)
2012-11-13math: use '#pragma STDC FENV_ACCESS ON' when fenv is accessedSzabolcs Nagy9-0/+10
2012-11-13math: excess precision fix modf, modff, scalbn, scalbnfSzabolcs Nagy4-22/+18
old code was correct only if the result was stored (without the excess precision) or musl was compiled with -ffloat-store. now we use STRICT_ASSIGN to work around the issue. (see note 160 in c11 section 6.8.6.4)
2012-11-13math: fix scalbn and scalbnf on overflow/underflowSzabolcs Nagy2-10/+24
old code was correct only if the result was stored (without the excess precision) or musl was compiled with -ffloat-store. (see note 160 in n1570.pdf section 6.8.6.4)
2012-11-13math: fix nextafter and nexttoward on maxdbl and maxflt inputSzabolcs Nagy4-4/+4
old code (return x+x;) returns correct value and raises correct flags only if the result is stored as double (or float)
2012-11-13math: raise flags in logl.c on <= 0 argumentsSzabolcs Nagy2-9/+3
2012-11-13math: fix logb*.c exceptions now that ilogb raises invalidSzabolcs Nagy3-25/+17
2012-11-13math: raise flags in log2l.c on <= 0 arguments, and fix volatileSzabolcs Nagy1-8/+3
2012-11-13math: raise exception flags in log1pl.c on <= -1 argumentsSzabolcs Nagy1-7/+2
2012-11-12math: raise invalid flag in ilogb*.c on +-0, +-inf and nanSzabolcs Nagy3-6/+18
2012-11-12math: fix exception behaviour of expm1l.c on inf and nanSzabolcs Nagy1-13/+7
2012-11-12math: fix long double constants in exp10l.cSzabolcs Nagy1-2/+2
2012-08-13Merge remote-tracking branch 'nsz/exp'Rich Felker2-40/+35
2012-08-13remove significandlRich Felker1-7/+0
this function never existed historically; since the float/double functions it's based on are nonstandard and deprecated, there's really no justification for its existence except that glibc has it. it can be added back if there's ever really a need...
2012-08-13add significand[fl] math functionsRich Felker3-0/+21
2012-08-08math: fix exp.s on i386 and x86_64 so the exception flags are correctnsz2-40/+35
exp(inf), exp(-inf), exp(nan) used to raise wrong flags
2012-07-02fix missing prototype and simplify sincosl on ld64 archsRich Felker1-4/+2
2012-07-02fix invalid implicit pointer conversion in ld64 modflRich Felker1-1/+1
2012-06-20math: fix fma bug on x86 (found by Bruno Haible with gnulib)nsz1-2/+10
The long double adjustment was wrong: The usual check is mant_bits & 0x7ff == 0x400 before doing a mant_bits++ or mant_bits-- adjustment since this is the only case when rounding an inexact ld80 into double can go wrong. (only in nearest rounding mode) After such a check the ++ and -- is ok (the mantissa will end in 0x401 or 0x3ff). fma is a bit different (we need to add 3 numbers with correct rounding: hi_xy + lo_xy + z so we should survive two roundings at different places without precision loss) The adjustment in fma only checks for zero low bits mant_bits & 0x3ff == 0 this way the adjusted value is correct when rounded to double or *less* precision. (this is an important piece in the fma puzzle) Unfortunately in this case the -- is not a correct adjustment because mant_bits might underflow so further checks are needed and this was the source of the bug.
2012-06-20support ld80 pseudo-denormal invalid bit patterns; treat them as nanRich Felker1-2/+5
this is silly, but it makes apps that read binary junk and interpret it as ld80 "safer", and it gets gnulib to stop replacing printf...
2012-06-02use fistpll mnemonic instead of fistpq (more widely supported) on x86_64 tooRich Felker1-1/+1
this was fixed previously on i386 but the corresponding code on x86_64 was missed.
2012-05-08math: fix remquo.c when x==-y and a subnormal remainder bug as wellnsz3-5/+8
backported fix from freebsd: http://svnweb.FreeBSD.org/base?view=revision&revision=233973
2012-05-07some assemblers don't like fistpq; use the alt. mnemonic fistpllRich Felker3-3/+3
2012-05-06add FORCE_EVAL macro to evaluate float expr for their side effectnsz5-24/+12
updated nextafter* to use FORCE_EVAL, it can be used in many other places in the math code to improve readability.
2012-05-06fix unused variable warnings in new nextafter/nexttoward codeRich Felker5-6/+12
apparently initializing a variable is not "using" it but assigning to it is "using" it. i don't really like this fix, but it's better than trying to make a bigger cleanup just before a release, and it should work fine (tested against nsz's math tests).
2012-05-06math: nextafter and nexttoward cleanupnsz5-291/+176
make nexttoward, nexttowardf independent of long double representation. fix nextafterl: it did not raise underflow flag when the result was 0.
2012-05-05math: change the formula used for acos.snsz2-20/+16
old: 2*atan2(sqrt(1-x),sqrt(1+x)) new: atan2(fabs(sqrt((1-x)*(1+x))),x) improvements: * all edge cases are fixed (sign of zero in downward rounding) * a bit faster (here a single call is about 131ns vs 162ns) * a bit more precise (at most 1ulp error on 1M uniform random samples in [0,1), the old formula gave some 2ulp errors as well)
2012-05-01support alternate glibc name pow10 for exp10Rich Felker3-0/+9
2012-04-30add C stub for sqrtl (already implemented in asm on i386 and x86_64)Rich Felker1-0/+9
2012-04-30first try at writing an efficient and "correct" exp10Rich Felker3-0/+55
this is a nonstandard function so it's not clear what conditions it should satisfy. my intent is that it be fast and exact for positive integral exponents when the result fits in the destination type, and fast and correctly rounded for small negative integral exponents. otherwise we aim for at most 1ulp error; it seems to differ from pow by at most 1ulp and it's often 2-5 times faster than pow.
2012-04-29fix typo in the x86_64 rounding asmRich Felker4-4/+4
2012-04-29new math asm (abs/rounding) for x86_64Rich Felker6-0/+36
untested
2012-04-04math: fix x86 asin accuracynsz2-5/+6
use (1-x)*(1+x) instead of (1-x*x) in asin.s the later can be inaccurate with upward rounding when x is close to 1
2012-03-29math: minor cleanups in ceil and floornsz5-10/+7
2012-03-29math: remove x86 modf asmnsz4-111/+0
the int part was wrong when -1 < x <= -0 (+0.0 instead of -0.0) and the size and performace gain of the asm version was negligible