bundles / scipy 1.17.1 / scipy / fft / _realtransforms / dctn
_Function
scipy.fft._realtransforms:dctn
source: /scipy/fft/_realtransforms.py :9
Signature
def dctn ( x , type = 2 , s = None , axes = None , norm = None , overwrite_x = False , workers = None , * , orthogonalize = None ) Summary
Return multidimensional Discrete Cosine Transform along the specified axes.
Parameters
x: array_likeThe input array.
type: {1, 2, 3, 4}, optionalType of the DCT (see Notes). Default type is 2.
s: int or array_like of ints or None, optionalThe shape of the result. If both
sandaxes(see below) are None,sisx.shape; ifsis None butaxesis not None, thensisnumpy.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 ofsis -1, the size of the corresponding dimension ofxis used.axes: int or array_like of ints or None, optionalAxes over which the DCT is computed. If not given, the last
len(s)axes are used, or all axes ifsis also not specified.norm: {"backward", "ortho", "forward"}, optionalNormalization mode (see Notes). Default is "backward".
overwrite_x: bool, optionalIf True, the contents of
xcan be destroyed; the default is False.workers: int, optionalMaximum number of workers to use for parallel computation. If negative, the value wraps around from
os.cpu_count(). See fft for more details.orthogonalize: bool, optionalWhether to use the orthogonalized DCT variant (see Notes). Defaults to
Truewhennorm="ortho"andFalseotherwise.
Returns
y: ndarray of realThe transformed input array.
Notes
For full details of the DCT types and normalization modes, as well as references, see dct.
Array API Standard Support
dctn has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ⛔ PyTorch ✅ ⛔ JAX ✅ ⛔ Dask ⚠️ computes graph n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
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)))✓
See also
- idctn
Inverse multidimensional DCT
Aliases
-
scipy.fft.dctn