Ilya Zakharevich on Mon, 16 Sep 2024 19:52:13 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: A missing (?) function: exponentfp(x) |
On Mon, Sep 16, 2024 at 07:13:39PM +0200, Bill Allombert wrote: > > > ? install(dbllog2,lG); > > > ? install(dbltor,L); > > > ? flog2(x)=dbltor(dbllog2(x)); > > > ? my(il2=1/log(2));setrand(1);for(i=1,10^6,log(random(1.)<<4)*il2) > > > cpu time = 3,868 ms, real time = 3,868 ms. > > > ? setrand(1);for(i=1,10^6,flog2(random(1.)<<4)) > > > cpu time = 655 ms, real time = 656 ms. > > > > On my Intel x64 CPU, this gives > > > > *** in function flog2: dbltor(dbllog2(x)) > > *** ^------------------ > > *** attempt to change built-in dbltor. > > > > Do not know whether it is related to the ABI problems Bill wrote > > about… > > This is unrelated. You probably did the install() after having defined > flog2(), so they were not taken into account by the bytecode compiler > when compiling flog2 This hits the bullet: repeating the definition of flog2() fixes this! And the result on my CPU is: 11 times slower than exponent()… (In the spirit of my other message on this thread, this would be a very good “second step” of “gradual improvement” of exponent() — on top of the step I advocate…) Thanks, Ilya P.S. Can the error message be made more clear?