File: fftpack.rst

package info (click to toggle)
python-scipy 0.10.1%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 42,232 kB
  • sloc: cpp: 224,773; ansic: 103,496; python: 85,210; fortran: 79,130; makefile: 272; sh: 43
file content (145 lines) | stat: -rw-r--r-- 3,909 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
Fourier Transforms (:mod:`scipy.fftpack`)
=========================================

.. sectionauthor:: Scipy Developers

.. currentmodule:: scipy.fftpack

.. warning::

   This is currently a stub page


.. contents::


Fourier analysis is fundamentally a method for expressing a function as a
sum of periodic components, and for recovering the signal from those
components.  When both the function and its Fourier transform are
replaced with discretized counterparts, it is called the discrete Fourier
transform (DFT).  The DFT has become a mainstay of numerical computing in
part because of a very fast algorithm for computing it, called the Fast
Fourier Transform (FFT), which was known to Gauss (1805) and was brought
to light in its current form by Cooley and Tukey [CT]_.  Press et al. [NR]_
provide an accessible introduction to Fourier analysis and its
applications.


Fast Fourier transforms
-----------------------

One dimensional discrete Fourier transforms
-------------------------------------------

fft, ifft, rfft, irfft


Two and n dimensional discrete Fourier transforms
-------------------------------------------------

fft in more than one dimension


Discrete Cosine Transforms
--------------------------


Return the Discrete Cosine Transform [Mak]_ of arbitrary type sequence ``x``.

For a single dimension array ``x``, ``dct(x, norm='ortho')`` is equal to
MATLAB ``dct(x)``.

There are theoretically 8 types of the DCT [WP]_, only the first 3 types are
implemented in scipy. 'The' DCT generally refers to DCT type 2, and 'the'
Inverse DCT generally refers to DCT type 3.

type I
~~~~~~

There are several definitions of the DCT-I; we use the following
(for ``norm=None``):

.. math::
   :nowrap:

    \[ y_k = x_0 + (-1)^k x_{N-1} + 2\sum_{n=1}^{N-2} x_n
    \cos\left({\pi nk\over N-1}\right),
    \qquad 0 \le k < N. \]

Only None is supported as normalization mode for DCT-I. Note also that the
DCT-I is only supported for input size > 1

type II
~~~~~~~

There are several definitions of the DCT-II; we use the following
(for ``norm=None``):

.. math::
   :nowrap:

    \[ y_k = 2 \sum_{n=0}^{N-1} x_n
    \cos \left({\pi(2n+1)k \over 2N} \right)
    \qquad 0 \le k < N.\]

If ``norm='ortho'``, :math:`y_k` is multiplied by a scaling factor `f`:

.. math::
   :nowrap:

    \[f = \begin{cases} \sqrt{1/(4N)}, & \text{if $k = 0$} \\
       \sqrt{1/(2N)}, & \text{otherwise} \end{cases} \]


Which makes the corresponding matrix of coefficients orthonormal
(`OO' = Id`).

type III
~~~~~~~~

There are several definitions, we use the following
(for ``norm=None``):

.. math::
   :nowrap:

    \[ y_k = x_0 + 2 \sum_{n=1}^{N-1} x_n
    \cos\left({\pi n(2k+1) \over 2N}\right)
    \qquad 0 \le k < N,\]

or, for ``norm='ortho'``:

.. math::
   :nowrap:

    \[ y_k = {x_0\over\sqrt{N}} + {1\over\sqrt{N}} \sum_{n=1}^{N-1}
    x_n \cos\left({\pi n(2k+1) \over 2N}\right)
    \qquad 0 \le k < N.\]

The (unnormalized) DCT-III is the inverse of the (unnormalized) DCT-II, up
to a factor `2N`. The orthonormalized DCT-III is exactly the inverse of the
orthonormalized DCT-II.

References
~~~~~~~~~~

.. [CT] Cooley, James W., and John W. Tukey, 1965, "An algorithm for the
        machine calculation of complex Fourier series," *Math. Comput.*
        19: 297-301.

.. [NR] Press, W., Teukolsky, S., Vetterline, W.T., and Flannery, B.P.,
        2007, *Numerical Recipes: The Art of Scientific Computing*, ch.
        12-13.  Cambridge Univ. Press, Cambridge, UK.

.. [Mak] J. Makhoul, 1980, 'A Fast Cosine Transform in One and Two Dimensions',
       `IEEE Transactions on acoustics, speech and signal processing`
       vol. 28(1), pp. 27-34, http://dx.doi.org/10.1109/TASSP.1980.1163351

.. [WP] http://en.wikipedia.org/wiki/Discrete_cosine_transform


FFT convolution
---------------

scipy.fftpack.convolve performs a convolution of two one-dimensional
arrays in frequency domain.