scipy.fft.dctn#
- scipy.fft.dctn(x, type=2, s=None, axes=None, norm=None, overwrite_x=False, workers=None, *, orthogonalize=None)[source]#
Return multidimensional Discrete Cosine Transform along the specified axes.
- Parameters:
- xarray_like
The input array.
- type{1, 2, 3, 4}, optional
Type of the DCT (see Notes). Default type is 2.
- sint or array_like of ints or None, optional
The shape of the result. If both s and axes (see below) are None, s is
x.shape
; if s is None but axes is not None, then s isnumpy.take(x.shape, axes, axis=0)
. Ifs[i] > x.shape[i]
, the ith dimension of the input is padded with zeros. Ifs[i] < x.shape[i]
, the ith dimension of the input is truncated to lengths[i]
. If any element of s is -1, the size of the corresponding dimension of x is used.- axesint or array_like of ints or None, optional
Axes over which the DCT is computed. If not given, the last
len(s)
axes are used, or all axes if s is also not specified.- norm{“backward”, “ortho”, “forward”}, optional
Normalization mode (see Notes). Default is “backward”.
- overwrite_xbool, optional
If True, the contents of x can be destroyed; the default is False.
- workersint, optional
Maximum number of workers to use for parallel computation. If negative, the value wraps around from
os.cpu_count()
. Seefft
for more details.- orthogonalizebool, optional
Whether to use the orthogonalized DCT variant (see Notes). Defaults to
True
whennorm="ortho"
andFalse
otherwise.Added in version 1.8.0.
- Returns:
- yndarray of real
The transformed input array.
See also
idctn
Inverse multidimensional DCT
Notes
For full details of the DCT types and normalization modes, as well as references, see
dct
.Examples
>>> import numpy as np >>> from scipy.fft import dctn, idctn >>> rng = np.random.default_rng() >>> y = rng.standard_normal((16, 16)) >>> np.allclose(y, idctn(dctn(y))) True