Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python35
/
lib64
/
python3.5
/
site-packages
/
scipy
/
fftpack
/
__pycache__
/
File Content:
helper.cpython-35.opt-1.pyc
��W� � @ s� d d l m Z m Z m Z d d l m Z d d l m Z m Z m Z d d l m Z d d d d d g Z d d d � Z d d � Z d S)� )�division�print_function�absolute_import)�arange)�fftshift� ifftshift�fftfreq)�bisect_leftr r r �rfftfreq� next_fast_leng �?c C sU t | t � s | d k r, t d | � � t d | d d t �d t | | � S)a� DFT sample frequencies (for usage with rfft, irfft). The returned float array contains the frequency bins in cycles/unit (with zero at the start) given a window length `n` and a sample spacing `d`:: f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2]/(d*n) if n is even f = [0,1,1,2,2,...,n/2-1,n/2-1,n/2,n/2]/(d*n) if n is odd Parameters ---------- n : int Window length. d : scalar, optional Sample spacing. Default is 1. Returns ------- out : ndarray The array of length `n`, containing the sample frequencies. Examples -------- >>> from scipy import fftpack >>> sig = np.array([-2, 8, 6, 4, 1, 0, 3, 5], dtype=float) >>> sig_fft = fftpack.rfft(sig) >>> n = sig_fft.size >>> timestep = 0.1 >>> freq = fftpack.rfftfreq(n, d=timestep) >>> freq array([ 0. , 1.25, 1.25, 2.5 , 2.5 , 3.75, 3.75, 5. ]) r z5n = %s is not valid. n must be a nonnegative integer.� Zdtype� )� isinstance�int� ValueErrorr �float)�n�d� r � /helper.pyr s " c � C s/ d� } | d� k r | S| | d� @s( | S| | d� k rI | t | | � St d� � } d� } x� | | k r| } xv | | k r� | | } d� | d� j � } | | } | | k r� | S| | k r� | } | d� 9} | | k rs | Sqs W| | k r� | } | d� 9} | | k r^ | Sq^ W| | k r+| } | S)�a� Find the next fast size of input data to `fft`, for zero-padding, etc. SciPy's FFTPACK has efficient functions for radix {2, 3, 4, 5}, so this returns the next composite of the prime factors 2, 3, and 5 which is greater than or equal to `target`. (These are also known as 5-smooth numbers, regular numbers, or Hamming numbers.) Parameters ---------- target : int Length to start searching from. Must be a positive integer. Returns ------- out : int The first 5-smooth number greater than or equal to `target`. Examples -------- On a particular machine, an FFT of prime length takes 133 ms: >>> from scipy import fftpack >>> min_len = 10007 # prime length is worst case for speed >>> a = np.random.randn(min_len) >>> b = fftpack.fft(a) Zero-padding to the next 5-smooth length reduces computation time to 211 us, a speedup of 630 times: >>> fftpack.helper.next_fast_len(min_len) 10125 >>> b = fftpack.fft(a, 10125) Rounding up to the next power of 2 is not optimal, taking 367 us to compute, 1.7 times as long as the 5-smooth size: >>> b = fftpack.fft(a, 16384) � � � � � � � � � � � � � �$ �( �- �0 �2 �6 �<