Aurel Page on Thu, 19 Sep 2024 09:39:29 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: A missing (?) function: exponentfp(x)


On 19/09/2024 06:30, Ilya Zakharevich wrote:
On Wed, Sep 18, 2024 at 10:38:09AM +0200, Aurel Page wrote:
? install("exponentfp","G");
? exponentfp(2^30-1)
%2 = 29.999999998656385002
? exponentfp(Pi)
%3 = 1.6514961294723207175
? z = Pi*2^20
%4 = 3294198.6583305710348142047482656880163
? for(i=1,10^6,exponent(z))
cpu time = 276 ms, real time = 276 ms.
? for(i=1,10^6,exponentfp(z))
cpu time = 312 ms, real time = 312 ms.
Hard to tell: on my (more than a decade old, cheap) laptop, the code
with exponent() takes 78 ms — but only 15 ms of them is taken by
exponent() itself.  Rescaling proportionally, this would make
exponentfp() twice as slow exponent() — which, if true, would be
REALLY GREAT!  Thanks!

However, to estimate THE REAL power of this, one needs to know the
timing of 

   ? for(i=1,10^6,(z))

(but I would redo everything with 10^8 — on some architectures
sub-0.1-seconds timing is not fully reliable…)5~

A Lot of Thanks again,
Ilya

  P.S.  Looking into the source, it probably does not support non-real
  	types; does it?

	For best results, it should better propagate better to other
  	types: fold()-by-max() for vectors/etc, fallback-to-exponent()
  	for non-real numeric types (etc?)…
Yes, this was a proof-of-concept, we can of course propagate it to other types.

Cheers,
Aurel