[Numpy-discussion] where are the benefits of ldexp and/or "array times 2"?

Gregor Thalhammer gregor.thalhammer@gmail....
Fri May 22 04:55:31 CDT 2009


dmitrey schrieb:
> Hi all,
> I expected to have some speedup via using ldexp or multiplying an
> array by a power of 2 (doesn't it have to perform a simple shift of
> mantissa?), but I don't see the one.
>
> # Let me also note -
> # 1) using b = 2 * ones(N) or b = zeros(N) doesn't yield any speedup
> vs b = rand()
> # 2) using A * 2.0 (or mere 2) instead of 2.1 doesn't yield any
> speedup, despite it is exact integer power of 2.
>   
On recent processors multiplication is very fast and takes 1.5 clock 
cycles (float, double precision), independent of the values. There is 
very little gain by using bit shift operators.

Gregor


More information about the Numpy-discussion mailing list