Date: Fri, 27 Jan 2012 20:01:18 +0100 From: Pascal Cuoq <pascal.cuoq@...il.com> To: musl@...ts.openwall.com Subject: Re: libm On Fri, Jan 27, 2012 at 5:02 PM, Szabolcs Nagy <nsz@...t70.net> wrote: > meanwhile i compared some implementations > openbsd, freebsd and glibc are worth to look at > Sorry to intrude in your conversation, but for reasons of my own I was recently looking for an aesthetically pleasing single-precision implementation of trigonometric functions, and some of the single-precisions functions out there are so ugly that I would seriously consider implementing these in musl by a call to their respective double-precision counterparts, despite the disadvantages. At least it's compact. Consider: http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libm/src/k_cosf.c?rev=1.3;content-type=text%2Fplain The code written at Sun and that many libms reuse must have been double-precision only, and someone had to make a single-precision version of them at some point. Without the analysis that led to the original code, one cannot blame Ian Lance Taylor for staying close to the double-precision function: http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libm/src/k_cos.c?rev=1.4;content-type=text%2Fplain But the degree of the polynomial in the single-precision version is about twice what is necessary, and the coefficients look like coefficients of the Taylor expansion rounded to nearest float, when they should be Chebyshev coefficients. Criticism is easy and art is difficult. I don't know how to write a better single-precision function, I just know that this one, for instance, cannot be good. Pascal Content of type "text/html" skipped
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.