Hi On Tue, Dec 25, 2001 at 01:41:23PM +0200, Nadav Har'El wrote: > On Tue, Dec 25, 2001, Shlomi Fish wrote about "Re: Implementation of log(x) for >SPARC32": > > Actually, usually glibc calls the processor's FPU logarithm routine. > > Oops, I didn't know the 386DX's FPU had a logarithm function on it... Nice :) > Do they also have things like sqrt and cbrt? >
They have many things. You can download from Intel a programmers guide, some of it is very interesting. E.g., they have a function f(x)=ln(1+x) for small x with full double accuracy (something you can't do with simple ln(x)). > > I did not say it is i386 specific. I'm sure it works fine on SPARCs. > > However, with things like math, there are separate routines for each > > architecture. And the SPARC's one is too obfuscated, and I cannot > > understand how I can rip the relevant code. > > Maybe SPARC doesn't have a magic-logarithm-blackbox on its CPU or FPU, so > it must use an actual algorithm to find the log - which is why it looks > more obfuscated than a simple call-the-fpu code. > > > FYI, I eventually gave up and coded a logarithm function in perl: > >.. > > Works like a charm with exactly the same accuracy. I'm going to convert it > > to C, and by this I will have a truly portable log() implementation for > > the kernel. > > Inventing your own wheels again, are you? :) > Your algorithm works, no doubt. So will nearly any other algorithm you'll > divise. What I doubt is that you can't do the same thing with half the number > of floating-point calculations (divisions, additions, comparisons), so > if you care about performance (maybe you don't, I don't know) you might > want to look for the *best* known algorithm, not just *an* algorithm. Maybe > your algorithm is alread the best possible - I don't know; In that case, > congradulations :) > > > IMO, someone should port stuff like a large part of glibc as well as STL, > > etc to the kernel. That would make the lives of programmers much easier > > because they won't have to reinvent the wheel times and again. > > But it will make the kernel huge... > And nobody needs logarithms or bessel functions and such stuff in the kernel > anyway, except perhaps your very specialized module. > > Next thing, you'll be asking to put a Java virtual machine inside the kernel. > It would have been useful to run syscalltrack expressions ;) > > -- > Nadav Har'El | Tuesday, Dec 25 2001, 10 Tevet 5762 > [EMAIL PROTECTED] |----------------------------------------- > Phone: +972-53-245868, ICQ 13349191 |Seen on the back of a dump truck: > http://nadav.harel.org.il |<---PASSING SIDE . . . . . SUICIDE---> > > ================================================================= > To unsubscribe, send mail to [EMAIL PROTECTED] with > the word "unsubscribe" in the message body, e.g., run the command > echo unsubscribe | mail [EMAIL PROTECTED] Didi ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]