# [Scipy-svn] r6883 - trunk/scipy/fftpack

scipy-svn@scip... scipy-svn@scip...
Sun Nov 14 03:58:14 CST 2010

```Author: rgommers
Date: 2010-11-14 03:58:13 -0600 (Sun, 14 Nov 2010)
New Revision: 6883

Modified:
trunk/scipy/fftpack/__init__.py
trunk/scipy/fftpack/basic.py
trunk/scipy/fftpack/realtransforms.py
Log:
DOC: merge wiki edits for fftpack module.

Modified: trunk/scipy/fftpack/__init__.py
===================================================================
--- trunk/scipy/fftpack/__init__.py	2010-11-14 09:57:53 UTC (rev 6882)
+++ trunk/scipy/fftpack/__init__.py	2010-11-14 09:58:13 UTC (rev 6883)
@@ -1,3 +1,57 @@
+"""
+Home of discrete Fourier transform algorithms
+
+Modules
+=======
+
+.. autosummary::
+   :toctree: generated/
+
+   basic - Basic discrete Fourier transform operators
+   convolve - Convolution functions
+   helper - TODO
+   pseudo_diffs - Differential and pseudo-differential operators
+   realtransforms - Real spectrum tranforms (DCT, DST, MDCT)
+
+Functions
+=========
+
+Fast Fourier Transforms (FFTs)
+------------------------------
+
+.. autosummary::
+   :toctree: generated/
+
+   fft - Fast (discrete) Fourier Transform (FFT)
+   ifft - Inverse FFT
+   fft2 - Two dimensional FFT
+   ifft2 - Two dimensional inverse FFT
+   fftn - n-dimensional FFT
+   ifftn - n-dimensional inverse FFT
+   rfft - FFT of strictly real-valued sequence
+   irfft - Inverse of rfft
+   rfftfreq - DFT sample frequencies (specific to rfft and irfft)
+   dct - Discrete cosine transform
+   idct - Inverse discrete cosine transform
+
+Differential and pseudo-differential operators
+----------------------------------------------
+
+.. autosummary::
+   :toctree: generated/
+
+   diff - Differentiation and integration of periodic sequences
+   tilbert - Tilbert transform:         cs_diff(x,h,h)
+   itilbert - Inverse Tilbert transform: sc_diff(x,h,h)
+   hilbert - Hilbert transform:         cs_diff(x,inf,inf)
+   ihilbert - Inverse Hilbert transform: sc_diff(x,inf,inf)
+   cs_diff - cosh/sinh pseudo-derivative of periodic sequences
+   sc_diff - sinh/cosh pseudo-derivative of periodic sequences
+   ss_diff - sinh/sinh pseudo-derivative of periodic sequences
+   cc_diff - cosh/cosh pseudo-derivative of periodic sequences
+   shift - Shift periodic sequences
+
+"""
#
# fftpack - Discrete Fourier Transform algorithms.
#

Modified: trunk/scipy/fftpack/basic.py
===================================================================
--- trunk/scipy/fftpack/basic.py	2010-11-14 09:57:53 UTC (rev 6882)
+++ trunk/scipy/fftpack/basic.py	2010-11-14 09:58:13 UTC (rev 6883)
@@ -219,17 +219,27 @@
return swapaxes(tmp, axis, -1)

def ifft(x, n=None, axis=-1, overwrite_x=0):
-    """ ifft(x, n=None, axis=-1, overwrite_x=0) -> y
+    """
+    Return discrete inverse Fourier transform of real or complex sequence.

-    Return inverse discrete Fourier transform of arbitrary type
-    sequence x.
+    The returned complex array contains ``y(0), y(1),..., y(n-1)`` where

-    The returned complex array contains
-      [y(0),y(1),...,y(n-1)]
-    where
-      y(j) = 1/n sum[k=0..n-1] x[k] * exp(sqrt(-1)*j*k* 2*pi/n)
+    ``y(j) = (x * exp(2*pi*sqrt(-1)*j*np.arange(n)/n)).mean()``.

-    Optional input: see fft.__doc__
+    Parameters
+    ----------
+    x : array_like
+        Transformed data to invert.
+    n : int, optional
+        Length of the inverse Fourier transform.  If ``n < x.shape[axis]``,
+        `x` is truncated.  If ``n > x.shape[axis]``, `x` is zero-padded.
+        The default results in ``n = x.shape[axis]``.
+    axis : int, optional
+        Axis along which the ifft's are computed; the default is over the
+        last axis (i.e., ``axis=-1``).
+    overwrite_x : bool, optional
+        If True the contents of `x` can be destroyed; the default is False.
+
"""
tmp = _asfarray(x)

@@ -263,31 +273,45 @@

def rfft(x, n=None, axis=-1, overwrite_x=0):
-    """ rfft(x, n=None, axis=-1, overwrite_x=0) -> y
+    """
+    Discrete Fourier transform of a real sequence.

-    Return discrete Fourier transform of real sequence x.
+    The returned real arrays contains::

-    The returned real arrays contains
[y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2))]              if n is even
[y(0),Re(y(1)),Im(y(1)),...,Re(y(n/2)),Im(y(n/2))]   if n is odd
+
where
-      y(j) = sum[k=0..n-1] x[k] * exp(-sqrt(-1)*j*k* 2*pi/n)
+    ::
+
+      y(j) = sum[k=0..n-1] x[k] * exp(-sqrt(-1)*j*k*2*pi/n)
j = 0..n-1
-    Note that y(-j) = y(n-j).conjugate().

-    Optional input:
-      n
-        Defines the length of the Fourier transform. If n is not
-        specified then n=x.shape[axis] is set. If n<x.shape[axis],
-        x is truncated. If n>x.shape[axis], x is zero-padded.
-      axis
-        The transform is applied along the given axis of the input
-        array (or the newly constructed array if n argument was used).
-      overwrite_x
-        If set to true, the contents of x can be destroyed.
+    Note that ``y(-j) == y(n-j).conjugate()``.

-    Notes:
-      y == rfft(irfft(y)) within numerical accuracy.
+    Parameters
+    ----------
+    x : array_like, real-valued
+        The data to tranform.
+    n : int, optional
+        Defines the length of the Fourier transform.  If `n` is not specified
+        (the default) then ``n = x.shape[axis]``.  If ``n < x.shape[axis]``,
+        `x` is truncated, if ``n > x.shape[axis]``, `x` is zero-padded.
+    axis : int, optional
+        The axis along which the transform is applied.  The default is the
+        last axis.
+    overwrite_x : bool, optional
+        If set to true, the contents of `x` can be overwritten. Default is
+        False.
+
+    --------
+    fft, irfft, scipy.fftpack.basic
+
+    Notes
+    -----
+    Within numerical accuracy, ``y == rfft(irfft(y))``.
+
"""
tmp = _asfarray(x)

@@ -479,11 +503,17 @@

def ifft2(x, shape=None, axes=(-2,-1), overwrite_x=0):
-    """ ifft2(x, shape=None, axes=(-2,-1), overwrite_x=0) -> y
+    """
+    2-D discrete inverse Fourier transform of real or complex sequence.

Return inverse two-dimensional discrete Fourier transform of
arbitrary type sequence x.

+
+    --------
+    fft2, ifft
+
"""
return ifftn(x,shape,axes,overwrite_x)

Modified: trunk/scipy/fftpack/realtransforms.py
===================================================================
--- trunk/scipy/fftpack/realtransforms.py	2010-11-14 09:57:53 UTC (rev 6882)
+++ trunk/scipy/fftpack/realtransforms.py	2010-11-14 09:58:13 UTC (rev 6883)
@@ -19,7 +19,7 @@

Parameters
----------
-    x : array-like
+    x : array_like
The input array.
type : {1, 2, 3}, optional
Type of the DCT (see Notes). Default type is 2.
@@ -42,7 +42,7 @@
Notes
-----
For a single dimension array ``x``, ``dct(x, norm='ortho')`` is equal to
-    matlab ``dct(x)``.
+    MATLAB ``dct(x)``.

There are theoretically 8 types of the DCT, only the first 3 types are
implemented in scipy. 'The' DCT generally refers to DCT type 2, and 'the'
@@ -115,11 +115,11 @@

def idct(x, type=2, n=None, axis=-1, norm=None):
"""
-    Return the Inverse Discrete Cosine Transform of arbitrary type sequence x.
+    Return the Inverse Discrete Cosine Transform of an arbitrary type sequence.

Parameters
----------
-    x : array-like
+    x : array_like
The input array.
type : {1, 2, 3}, optional
Type of the DCT (see Notes). Default type is 2.

```