[SciPy-User] frequency components of a signal buried in a noisy time domain signal

Charles R Harris charlesr.harris at gmail.com
Sat Feb 27 13:57:46 EST 2010


On Sat, Feb 27, 2010 at 11:32 AM, Ivo Maljevic <ivo.maljevic at gmail.com>wrote:

> Thanks Robert. I figured that after I sent the question, but I am not sure
> if the search based solution offers any advantage in terms of speed.
> Besides, and not that it matters really, but that solution restricts the
> usage to max 2**32 integer result on 32 bit machines, whereas log based one
> doesn't:
>
> >>> def nextpow2(n):
> ...   return 2**(np.ceil(np.log2(n)))
> ...
> >>> np.iinfo(np.intp).bits
> 32
> >>> n=2**32+300.5
> >>> n
> 4294967596.5
> >>> nextpow2(n)
> 8589934592.0
>
>
For (ieee) floats

In [17]: def nextpow2(x) : return np.ldexp(1., np.frexp(x)[1])
   ....:

In [18]: nextpow2(2**32+300.5)
Out[18]: 8589934592.0


Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20100227/576bb669/attachment.html>


More information about the SciPy-User mailing list