<feed xmlns='http://www.w3.org/2005/Atom'>
<title>musl/src/math, branch v0.9.9</title>
<subtitle>musl - an implementation of the standard library for Linux-based systems</subtitle>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/'/>
<entry>
<title>math: erf and erfc cleanup</title>
<updated>2013-01-07T22:54:13+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2013-01-07T22:54:13+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=121e3a38a1d0b324696fc1671029e4b815ea7fa4'/>
<id>121e3a38a1d0b324696fc1671029e4b815ea7fa4</id>
<content type='text'>
common part of erf and erfc was put in a separate function which
saved some space and the new code is using unsigned arithmetics

erfcf had a bug: for some inputs in [7.95,8] the result had
more than 60ulp error: in expf(-z*z - 0.5625f) the argument
must be exact but not enough lowbits of z were zeroed,
-SET_FLOAT_WORD(z, ix&amp;0xfffff000);
+SET_FLOAT_WORD(z, ix&amp;0xffffe000);
fixed the issue
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
common part of erf and erfc was put in a separate function which
saved some space and the new code is using unsigned arithmetics

erfcf had a bug: for some inputs in [7.95,8] the result had
more than 60ulp error: in expf(-z*z - 0.5625f) the argument
must be exact but not enough lowbits of z were zeroed,
-SET_FLOAT_WORD(z, ix&amp;0xfffff000);
+SET_FLOAT_WORD(z, ix&amp;0xffffe000);
fixed the issue
</pre>
</div>
</content>
</entry>
<entry>
<title>math: bessel cleanup (jn.c and jnf.c)</title>
<updated>2013-01-01T21:20:45+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2013-01-01T21:20:45+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=5652d70054daf3c2c9b6d475fdf9d24a940e51aa'/>
<id>5652d70054daf3c2c9b6d475fdf9d24a940e51aa</id>
<content type='text'>
both jn and yn functions had integer overflow issues for large
and small n

to handle these issues nm1 (== |n|-1) is used instead of n and -n
in the code and some loops are changed to make sure the iteration
counter does not overflow

(another solution could be to use larger integer type or even double
but that has more size and runtime cost, on x87 loading int64_t or
even uint32_t into an fpu register is more than two times slower than
loading int32_t, and using double for n slows down iteration logic)

yn(-1,0) now returns inf

posix2008 specifies that on overflow and at +-0 all y0,y1,yn functions
return -inf, this is not consistent with math when n&lt;0 odd integer in yn
(eg. when x-&gt;0, yn(-1,x)-&gt;inf, but historically yn(-1,0) seems to be
special cased and returned -inf)

some threshold values in jnf and ynf were fixed that seems to be
incorrectly copy-pasted from the double version
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
both jn and yn functions had integer overflow issues for large
and small n

to handle these issues nm1 (== |n|-1) is used instead of n and -n
in the code and some loops are changed to make sure the iteration
counter does not overflow

(another solution could be to use larger integer type or even double
but that has more size and runtime cost, on x87 loading int64_t or
even uint32_t into an fpu register is more than two times slower than
loading int32_t, and using double for n slows down iteration logic)

yn(-1,0) now returns inf

posix2008 specifies that on overflow and at +-0 all y0,y1,yn functions
return -inf, this is not consistent with math when n&lt;0 odd integer in yn
(eg. when x-&gt;0, yn(-1,x)-&gt;inf, but historically yn(-1,0) seems to be
special cased and returned -inf)

some threshold values in jnf and ynf were fixed that seems to be
incorrectly copy-pasted from the double version
</pre>
</div>
</content>
</entry>
<entry>
<title>math: bessel cleanup (j1.c and j1f.c)</title>
<updated>2013-01-01T21:11:28+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2013-01-01T21:11:28+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=5bb6b24952e3f95ede42b60ac64a33ac34b8e272'/>
<id>5bb6b24952e3f95ede42b60ac64a33ac34b8e272</id>
<content type='text'>
a common code path in j1 and y1 was factored out so the resulting
object code is a bit smaller

unsigned int arithmetics is used for bit manipulation

j1(-inf) now returns 0 instead of -0

an incorrect threshold in the common code of j1f and y1f got fixed
(this caused spurious overflow and underflow exceptions)

the else branch in pone and pzero functions are fixed
(so code analyzers dont warn about uninitialized values)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
a common code path in j1 and y1 was factored out so the resulting
object code is a bit smaller

unsigned int arithmetics is used for bit manipulation

j1(-inf) now returns 0 instead of -0

an incorrect threshold in the common code of j1f and y1f got fixed
(this caused spurious overflow and underflow exceptions)

the else branch in pone and pzero functions are fixed
(so code analyzers dont warn about uninitialized values)
</pre>
</div>
</content>
</entry>
<entry>
<title>math: bessel cleanup (j0.c and j0f.c)</title>
<updated>2013-01-01T20:59:46+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2013-01-01T20:59:46+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=697acde67e0da4d73b46445ed536fe9923d515c7'/>
<id>697acde67e0da4d73b46445ed536fe9923d515c7</id>
<content type='text'>
a common code path in j0 and y0 was factored out so the resulting
object code is smaller

unsigned int arithmetics is used for bit manipulation

the logic of j0 got a bit simplified (x &lt; 1 case was handled
separately with a bit higher precision than now, but there are large
errors in other domains anyway so that branch has been removed)

some threshold values were adjusted in j0f and y0f
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
a common code path in j0 and y0 was factored out so the resulting
object code is smaller

unsigned int arithmetics is used for bit manipulation

the logic of j0 got a bit simplified (x &lt; 1 case was handled
separately with a bit higher precision than now, but there are large
errors in other domains anyway so that branch has been removed)

some threshold values were adjusted in j0f and y0f
</pre>
</div>
</content>
</entry>
<entry>
<title>math: use 0x1p-120f and 0x1p120f for tiny and huge values</title>
<updated>2012-12-16T19:28:43+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2012-12-16T19:28:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=c6383b7b10303457306932584fc23f24b5153a81'/>
<id>c6383b7b10303457306932584fc23f24b5153a81</id>
<content type='text'>
previously 0x1p-1000 and 0x1p1000 was used for raising inexact
exception like x+tiny (when x is big) or x+huge (when x is small)

the rational is that these float consts are large enough
(0x1p-120 + 1 raises inexact even on ld128 which has 113 mant bits)
and float consts maybe smaller or easier to load on some platforms
(on i386 this reduced the object file size by 4bytes in some cases)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
previously 0x1p-1000 and 0x1p1000 was used for raising inexact
exception like x+tiny (when x is big) or x+huge (when x is small)

the rational is that these float consts are large enough
(0x1p-120 + 1 raises inexact even on ld128 which has 113 mant bits)
and float consts maybe smaller or easier to load on some platforms
(on i386 this reduced the object file size by 4bytes in some cases)
</pre>
</div>
</content>
</entry>
<entry>
<title>math: tgammal.c fixes</title>
<updated>2012-12-16T19:22:17+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2012-12-16T19:22:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=d8a7619e371ff0f226200f6316abb46dd1192f3d'/>
<id>d8a7619e371ff0f226200f6316abb46dd1192f3d</id>
<content type='text'>
this is not a full rewrite just fixes to the special case logic:
+-0 and non-integer x&lt;INT_MIN inputs incorrectly raised invalid
exception and for +-0 the return value was wrong

so integer test and odd/even test for negative inputs are changed
and a useless overflow test was removed
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
this is not a full rewrite just fixes to the special case logic:
+-0 and non-integer x&lt;INT_MIN inputs incorrectly raised invalid
exception and for +-0 the return value was wrong

so integer test and odd/even test for negative inputs are changed
and a useless overflow test was removed
</pre>
</div>
</content>
</entry>
<entry>
<title>math: tanh.c cleanup similar to sinh, cosh</title>
<updated>2012-12-16T18:52:42+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2012-12-16T18:52:42+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=e42a977fe5dbe48ba45072ab82886e6b5a694487'/>
<id>e42a977fe5dbe48ba45072ab82886e6b5a694487</id>
<content type='text'>
comments are kept in the double version of the function

compared to fdlibm/freebsd we partition the domain into one
more part and select different threshold points:
now the [log(5/3)/2,log(3)/2] and [log(3)/2,inf] domains
should have &lt;1.5ulp error
(so only the last bit may be wrong, assuming good exp, expm1)

(note that log(3)/2 and log(5/3)/2 are the points where tanh
changes resolution: tanh(log(3)/2)=0.5, tanh(log(5/3)/2)=0.25)

for some x &lt; log(5/3)/2 (~=0.2554) the error can be &gt;1.5ulp
but it should be &lt;2ulp
(the freebsd code had some &gt;2ulp errors in [0.255,1])

even with the extra logic the new code produces smaller
object files
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
comments are kept in the double version of the function

compared to fdlibm/freebsd we partition the domain into one
more part and select different threshold points:
now the [log(5/3)/2,log(3)/2] and [log(3)/2,inf] domains
should have &lt;1.5ulp error
(so only the last bit may be wrong, assuming good exp, expm1)

(note that log(3)/2 and log(5/3)/2 are the points where tanh
changes resolution: tanh(log(3)/2)=0.5, tanh(log(5/3)/2)=0.25)

for some x &lt; log(5/3)/2 (~=0.2554) the error can be &gt;1.5ulp
but it should be &lt;2ulp
(the freebsd code had some &gt;2ulp errors in [0.255,1])

even with the extra logic the new code produces smaller
object files
</pre>
</div>
</content>
</entry>
<entry>
<title>math: sinh.c cleanup similar to the cosh one</title>
<updated>2012-12-16T18:49:55+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2012-12-16T18:49:55+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=f143458223f90262a9c2d929f9e815a74e3aa139'/>
<id>f143458223f90262a9c2d929f9e815a74e3aa139</id>
<content type='text'>
comments are kept in the double version of the function
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
comments are kept in the double version of the function
</pre>
</div>
</content>
</entry>
<entry>
<title>math: finished cosh.c cleanup</title>
<updated>2012-12-16T18:23:51+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2012-12-16T18:23:51+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=1aec620f9366c29d761fe42b3e02bd8024685db3'/>
<id>1aec620f9366c29d761fe42b3e02bd8024685db3</id>
<content type='text'>
changed the algorithm: large input is not special cased
(when exp(-x) is small compared to exp(x))
and the threshold values are reevaluated
(fdlibm code had a log(2)/2 cutoff for which i could not find
justification, log(2) seems to be a better threshold and this
was verified empirically)

the new code is simpler, makes smaller binaries and should be
faster for common cases

the old comments were removed as they are no longer true for the
new algorithm and the fdlibm copyright was dropped as well
because there is no common code or idea with the original anymore
except for trivial ones.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
changed the algorithm: large input is not special cased
(when exp(-x) is small compared to exp(x))
and the threshold values are reevaluated
(fdlibm code had a log(2)/2 cutoff for which i could not find
justification, log(2) seems to be a better threshold and this
was verified empirically)

the new code is simpler, makes smaller binaries and should be
faster for common cases

the old comments were removed as they are no longer true for the
new algorithm and the fdlibm copyright was dropped as well
because there is no common code or idea with the original anymore
except for trivial ones.
</pre>
</div>
</content>
</entry>
<entry>
<title>math: x86_64 version of expl, fixed some comments in the i386 version</title>
<updated>2012-12-16T16:30:29+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2012-12-16T16:30:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=58bba42d1bd14e1ab01f3249ffc98afdbf841a6a'/>
<id>58bba42d1bd14e1ab01f3249ffc98afdbf841a6a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
