summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-06-15 03:29:11 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-06-15 03:29:11 +0000
commit439ea9dc39d6ab0c4052b0881d0f6fed5e8c344f (patch)
tree69c096c4b73254f6b11a3cecb24f12d6d2327010
parentd5a134b8bc96cf1e63c31c0ce933e442adb77c2a (diff)
downloadnumpy-439ea9dc39d6ab0c4052b0881d0f6fed5e8c344f.tar.gz
Make refft -> rfft and have old names for backwards compatibility.
-rw-r--r--numpy/core/src/arrayobject.c5
-rw-r--r--numpy/dft/fftpack.py74
2 files changed, 46 insertions, 33 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index c77f3f91d..38347355d 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -3709,6 +3709,11 @@ PyArray_CompareUCS4(PyArray_UCS4 *s1, PyArray_UCS4 *s2, register size_t len)
}
/* This also handles possibly mis-aligned data */
+/* Compare s1 and s2 which are not necessarily NULL-terminated.
+ s1 is of length len1
+ s2 is of length len2
+ If they are NULL terminated, then stop comparison.
+*/
static int
_myunincmp(PyArray_UCS4 *s1, PyArray_UCS4 *s2, int len1, int len2)
{
diff --git a/numpy/dft/fftpack.py b/numpy/dft/fftpack.py
index 22e236370..4b88651ef 100644
--- a/numpy/dft/fftpack.py
+++ b/numpy/dft/fftpack.py
@@ -6,21 +6,22 @@ version of the FFTPACK routines.
fft(a, n=None, axis=-1)
ifft(a, n=None, axis=-1)
-refft(a, n=None, axis=-1)
-irefft(a, n=None, axis=-1)
+rfft(a, n=None, axis=-1)
+irfft(a, n=None, axis=-1)
hfft(a, n=None, axis=-1)
ihfft(a, n=None, axis=-1)
fftn(a, s=None, axes=None)
ifftn(a, s=None, axes=None)
-refftn(a, s=None, axes=None)
-irefftn(a, s=None, axes=None)
+rfftn(a, s=None, axes=None)
+irfftn(a, s=None, axes=None)
fft2(a, s=None, axes=(-2,-1))
ifft2(a, s=None, axes=(-2, -1))
-refft2(a, s=None, axes=(-2,-1))
-irefft2(a, s=None, axes=(-2, -1))
+rfft2(a, s=None, axes=(-2,-1))
+irfft2(a, s=None, axes=(-2, -1))
"""
-__all__ = ['fft','ifft', 'refft', 'irefft', 'hfft', 'ihfft', 'refftn',
- 'irefftn', 'refft2', 'irefft2', 'fft2', 'ifft2', 'fftn', 'ifftn']
+__all__ = ['fft','ifft', 'rfft', 'irfft', 'hfft', 'ihfft', 'rfftn',
+ 'irfftn', 'rfft2', 'irfft2', 'fft2', 'ifft2', 'fftn', 'ifftn',
+ 'refft', 'irefft','refftn','irefftn', 'refft2', 'irefft2']
from numpy.core import asarray, zeros, swapaxes, shape, conjugate, \
take
@@ -111,8 +112,8 @@ def ifft(a, n=None, axis=-1):
return _raw_fft(a, n, axis, fftpack.cffti, fftpack.cfftb, _fft_cache) / n
-def refft(a, n=None, axis=-1):
- """refft(a, n=None, axis=-1)
+def rfft(a, n=None, axis=-1):
+ """rfft(a, n=None, axis=-1)
Will return the n point discrete Fourier transform of the real valued
array a. n defaults to the length of a. n is the length of the input, not
@@ -132,8 +133,8 @@ def refft(a, n=None, axis=-1):
return _raw_fft(a, n, axis, fftpack.rffti, fftpack.rfftf, _real_fft_cache)
-def irefft(a, n=None, axis=-1):
- """irefft(a, n=None, axis=-1)
+def irfft(a, n=None, axis=-1):
+ """irfft(a, n=None, axis=-1)
Will return the real valued n point inverse discrete Fourier transform of
a, where a contains the nonnegative frequency terms of a Hermite-symmetric
@@ -144,10 +145,10 @@ def irefft(a, n=None, axis=-1):
If you specify an n such that a must be zero-padded or truncated, the
extra/removed values will be added/removed at high frequencies. One can
thus resample a series to m points via Fourier interpolation by: a_resamp
- = irefft(refft(a), m).
+ = irfft(rfft(a), m).
- This is the inverse of refft:
- irefft(refft(a), len(a)) == a
+ This is the inverse of rfft:
+ irfft(rfft(a), len(a)) == a
within numerical accuracy."""
a = asarray(a).astype(complex)
@@ -161,7 +162,7 @@ def hfft(a, n=None, axis=-1):
"""hfft(a, n=None, axis=-1)
ihfft(a, n=None, axis=-1)
- These are a pair analogous to refft/irefft, but for the
+ These are a pair analogous to rfft/irfft, but for the
opposite case: here the signal is real in the frequency domain and has
Hermite symmetry in the time domain. So here it's hermite_fft for which
you must supply the length of the result if it is to be odd.
@@ -172,14 +173,14 @@ def hfft(a, n=None, axis=-1):
a = asarray(a).astype(complex)
if n == None:
n = (shape(a)[axis] - 1) * 2
- return irefft(conjugate(a), n, axis) * n
+ return irfft(conjugate(a), n, axis) * n
def ihfft(a, n=None, axis=-1):
"""hfft(a, n=None, axis=-1)
ihfft(a, n=None, axis=-1)
- These are a pair analogous to refft/irefft, but for the
+ These are a pair analogous to rfft/irfft, but for the
opposite case: here the signal is real in the frequency domain and has
Hermite symmetry in the time domain. So here it's hfft for which
you must supply the length of the result if it is to be odd.
@@ -190,7 +191,7 @@ def ihfft(a, n=None, axis=-1):
a = asarray(a).astype(float)
if n == None:
n = shape(a)[axis]
- return conjugate(refft(a, n, axis))/n
+ return conjugate(rfft(a, n, axis))/n
def _cook_nd_args(a, s=None, axes=None, invreal=0):
@@ -265,8 +266,8 @@ def ifft2(a, s=None, axes=(-2,-1)):
return _raw_fftnd(a, s, axes, ifft)
-def refftn(a, s=None, axes=None):
- """refftn(a, s=None, axes=None)
+def rfftn(a, s=None, axes=None):
+ """rfftn(a, s=None, axes=None)
The n-dimensional discrete Fourier transform of a real array a. A real
transform as real_fft is performed along the axis specified by the last
@@ -275,24 +276,24 @@ def refftn(a, s=None, axes=None):
a = asarray(a).astype(float)
s, axes = _cook_nd_args(a, s, axes)
- a = refft(a, s[-1], axes[-1])
+ a = rfft(a, s[-1], axes[-1])
for ii in range(len(axes)-1):
a = fft(a, s[ii], axes[ii])
return a
-def refft2(a, s=None, axes=(-2,-1)):
- """refft2(a, s=None, axes=(-2,-1))
+def rfft2(a, s=None, axes=(-2,-1)):
+ """rfft2(a, s=None, axes=(-2,-1))
- The 2d fft of the real valued array a. This is really just refftn with
+ The 2d fft of the real valued array a. This is really just rfftn with
different default behavior."""
return real_fftnd(a, s, axes)
-def irefftn(a, s=None, axes=None):
- """irefftn(a, s=None, axes=None)
+def irfftn(a, s=None, axes=None):
+ """irfftn(a, s=None, axes=None)
- The inverse of refftn. The transform implemented in inverse_fft is
+ The inverse of rfftn. The transform implemented in inverse_fft is
applied along all axes but the last, then the transform implemented in
inverse_real_fft is performed along the last axis. As with
inverse_real_fft, the length of the result along that axis must be
@@ -302,14 +303,21 @@ def irefftn(a, s=None, axes=None):
s, axes = _cook_nd_args(a, s, axes, invreal=1)
for ii in range(len(axes)-1):
a = ifft(a, s[ii], axes[ii])
- a = irefft(a, s[-1], axes[-1])
+ a = irfft(a, s[-1], axes[-1])
return a
-def irefft2(a, s=None, axes=(-2,-1)):
- """irefft2(a, s=None, axes=(-2, -1))
+def irfft2(a, s=None, axes=(-2,-1)):
+ """irfft2(a, s=None, axes=(-2, -1))
- The inverse of refft2. This is really just irefftn with
+ The inverse of rfft2. This is really just irfftn with
different default behavior."""
- return irefftn(a, s, axes)
+ return irfftn(a, s, axes)
+# Deprecated names
+refft = rfft
+irefft = irfft
+refft2 = rfft2
+irefft2 = irfft2
+refftn = rfftn
+irefftn = irfftn