The Python user imports the numarray.fft module, which provides a set of utility functions of the most commonly used FFT routines, and allows the specification of which axes (dimensions) of the input arrays are to be used for the FFT's. These routines are:
a, n=None, axis=-1) |
len(a)
, then a will be
zero-padded to make up the difference. If n is smaller than
len(a)
, then a will be aliased to reduce its size. This
also stores a cache of working memory for different sizes of
fft's, so you could theoretically run into memory problems if
you call this too many times with too many different n's.
The FFT is performed along the axis indicated by the axis argument, which defaults to be the last dimension of a.
The format of the returned array is a complex array of the same shape as a, where the first element in the result array contains the DC (steady-state) value of the FFT.
Some examples are:
>>> a = array([1., 0., 1., 0., 1., 0., 1., 0.]) + 10 >>> b = array([0., 1., 0., 1., 0., 1., 0., 1.]) + 10 >>> c = array([0., 1., 0., 0., 0., 1., 0., 0.]) + 10 >>> print numarray.fft.fft(a).real [ 84. 0. 0. 0. 4. 0. 0. 0.] >>> print numarray.fft.fft(b).real [ 84. 0. 0. 0. -4. 0. 0. 0.] >>> print numarray.fft.fft(c).real [ 82. 0. 0. 0. -2. 0. 0. 0.]
a, n=None, axis=-1) |
a, n=None, axis=-1) |
>>> x = cos(arange(30.0)/30.0*2*pi) >>> print numarray.fft.real_fft(x) [ -5.82867088e-16 +0.00000000e+00j 1.50000000e+01 -3.08862614e-15j 7.13643755e-16 -1.04457106e-15j 1.13047653e-15 -3.23843935e-15j -1.52158521e-15 +1.14787259e-15j 3.60822483e-16 +3.60555504e-16j 1.34237661e-15 +2.05127011e-15j 1.98981960e-16 -1.02472357e-15j 1.55899290e-15 -9.94619821e-16j -1.05417678e-15 -2.33364171e-17j -2.08166817e-16 +1.00955541e-15j -1.34094426e-15 +8.88633386e-16j 5.67513742e-16 -2.24823896e-15j 2.13735778e-15 -5.68448962e-16j -9.55398954e-16 +7.76890265e-16j -1.05471187e-15 +0.00000000e+00j]
a, n=None, axis=-1) |
a, s=None, axes=(-2,-1)) |
a, s=None, axes=(-2,-1)) |
a, s=None, axes=(-2,-1)) |
a, s=None, axes=(-2,-1)) |
Send comments to the NumArray community.