Skip to content

Commit

Permalink
DOC: merge wiki edits - fftpack module.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgommers committed May 24, 2010
1 parent 85d2df8 commit 7b6be03
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 61 deletions.
14 changes: 9 additions & 5 deletions scipy/fftpack/basic.py
Expand Up @@ -408,19 +408,23 @@ def _raw_fftn_dispatch(x, shape, axes, overwrite_x, direction):


def ifftn(x, shape=None, axes=None, overwrite_x=0):
""" ifftn(x, s=None, axes=None, overwrite_x=0) -> y
"""
Return inverse multi-dimensional discrete Fourier transform of
arbitrary type sequence x.
The returned array contains
The returned array contains::
y[j_1,..,j_d] = 1/p * sum[k_1=0..n_1-1, ..., k_d=0..n_d-1]
x[k_1,..,k_d] * prod[i=1..d] exp(sqrt(-1)*2*pi/n_i * j_i * k_i)
where d = len(x.shape), n = x.shape, and p = prod[i=1..d] n_i.
where ``d = len(x.shape)``, ``n = x.shape``, and ``p = prod[i=1..d] n_i``.
For description of parameters see `fftn`.
See Also
--------
fftn : for detailed information.
Optional input: see fftn.__doc__
"""
return _raw_fftn_dispatch(x, shape, axes, overwrite_x, -1)

Expand Down
22 changes: 13 additions & 9 deletions scipy/fftpack/pseudo_diffs.py
Expand Up @@ -252,26 +252,30 @@ def kernel(k,a=a,b=b):
_cache = {}
def sc_diff(x, a, b, period=None,
_cache = _cache):
""" sc_diff(x, a, b, period=2*pi) -> y
"""
Return (a,b)-sinh/cosh pseudo-derivative of a periodic sequence x.
If x_j and y_j are Fourier coefficients of periodic functions x
and y, respectively, then
and y, respectively, then::
y_j = sqrt(-1)*sinh(j*a*2*pi/period)/cosh(j*b*2*pi/period) * x_j
y_0 = 0
Input:
a,b
Parameters
----------
x : array_like
Input array.
a,b : float
Defines the parameters of the sinh/cosh pseudo-differential
operator.
period
period : float, optional
The period of the sequence x. Default is 2*pi.
Notes:
sc_diff(cs_diff(x,a,b),b,a) == x
For even len(x), the Nyquist mode of x is taken zero.
Notes
-----
``sc_diff(cs_diff(x,a,b),b,a) == x``
For even ``len(x)``, the Nyquist mode of x is taken as zero.
"""
tmp = asarray(x)
if iscomplexobj(tmp):
Expand Down
98 changes: 51 additions & 47 deletions scipy/fftpack/realtransforms.py
Expand Up @@ -20,19 +20,24 @@ def dct(x, type=2, n=None, axis=-1, norm=None):
Parameters
----------
x : array-like
input array.
type : {1, 2, 3}
type of the DCT (see Notes).
The input array.
type : {1, 2, 3}, optional
Type of the DCT (see Notes). Default type is 2.
n : int, optional
Length of the transform.
axis : int, optional
axis over which to compute the transform.
norm : {None, 'ortho'}
normalization mode (see Notes).
Axis over which to compute the transform.
norm : {None, 'ortho'}, optional
Normalization mode (see Notes). Default is None.
Returns
-------
y : real ndarray
y : ndarray of real
The transformed input array.
See Also
--------
idct
Notes
-----
Expand All @@ -46,56 +51,52 @@ def dct(x, type=2, n=None, axis=-1, norm=None):
type I
~~~~~~
There are several definitions of the DCT-I; we use the following
(for ``norm=None``):
(for ``norm=None``)::
.. math::
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.
N-2
y[k] = x[0] + (-1)**k x[N-1] + 2 * sum x[n]*cos(pi*k*n/(N-1))
n=1
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``):
(for ``norm=None``)::
.. math::
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`:
N-1
y[k] = 2* sum x[n]*cos(pi*k*(2n+1)/(2*N)), 0 <= k < N.
n=0
.. math::
f = \\begin{cases} \\sqrt{1/(4N)}, & \\text{if $k = 0$} \\\\
\t\t\\sqrt{1/(2N)}, & \\text{otherwise} \\end{cases}
If ``norm='ortho'``, ``y[k]`` is multiplied by a scaling factor `f`::
f = sqrt(1/(4*N)) if k = 0,
f = sqrt(1/(2*N)) otherwise.
Which makes the corresponding matrix of coefficients orthonormal
(`OO' = Id`).
(``OO' = Id``).
type III
~~~~~~~~
There are several definitions, we use the following
(for ``norm=None``):
(for ``norm=None``)::
.. math::
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,
N-1
y[k] = x[0] + 2 * sum x[n]*cos(pi*(k+0.5)*n/N), 0 <= k < N.
n=1
or, for ``norm='ortho'``:
or, for ``norm='ortho'`` and 0 <= k < N::
.. math::
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.
N-1
y[k] = x[0] / sqrt(N) + sqrt(1/N) * sum x[n]*cos(pi*(k+0.5)*n/N)
n=1
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.
to a factor `2N`. The orthonormalized DCT-III is exactly the inverse of
the orthonormalized DCT-II.
References
----------
Expand All @@ -119,33 +120,36 @@ def idct(x, type=2, n=None, axis=-1, norm=None):
Parameters
----------
x : array-like
input array.
type : {1, 2, 3}
type of the IDCT (see Notes).
The input array.
type : {1, 2, 3}, optional
Type of the DCT (see Notes). Default type is 2.
n : int, optional
Length of the transform.
axis : int, optional
axis over which to compute the transform.
norm : {None, 'ortho'}
normalization mode (see Notes).
Axis over which to compute the transform.
norm : {None, 'ortho'}, optional
Normalization mode (see Notes). Default is None.
Returns
-------
y : real ndarray
y : ndarray of real
The transformed input array.
See Also
--------
dct
Notes
-----
For a single dimension array x, idct(x, norm='ortho') is equal to matlab
idct(x)
For a single dimension array `x`, ``idct(x, norm='ortho')`` is equal to
matlab ``idct(x)``.
'The' IDCT is the IDCT of type 2, which is the same as DCT of type 3.
IDCT of type 1 is the DCT of type 1, IDCT of type 2 is the DCT of type 3,
and IDCT of type 3 is the DCT of type 2.
and IDCT of type 3 is the DCT of type 2. For the definition of these types,
see `dct`.
See Also
--------
dct
"""
if type == 1 and norm is not None:
raise NotImplementedError(
Expand Down

0 comments on commit 7b6be03

Please sign in to comment.