jax.scipy.fft.idct#
- jax.scipy.fft.idct(x, type=2, n=None, axis=-1, norm=None)[source]#
Computes the inverse discrete cosine transform of the input
JAX implementation of
scipy.fft.idct()
.- Parameters:
x (Array) – array
type (int) – integer, default = 2. Currently only type 2 is supported.
n (int | None | None) – integer, default = x.shape[axis]. The length of the transform. If larger than
x.shape[axis]
, the input will be zero-padded, if smaller, the input will be truncated.axis (int) – integer, default=-1. The axis along which the dct will be performed.
norm (str | None | None) – string. The normalization mode: one of
[None, "backward", "ortho"]
. The default isNone
, which is equivalent to"backward"
.
- Returns:
array containing the inverse discrete cosine transform of x
- Return type:
See also
jax.scipy.fft.dct()
: DCTjax.scipy.fft.dctn()
: multidimensional DCTjax.scipy.fft.idctn()
: multidimensional inverse DCT
Examples
>>> x = jax.random.normal(jax.random.key(0), (3, 3)) >>> with jnp.printoptions(precision=2, suppress=True): ... print(jax.scipy.fft.idct(x)) [[ 0.78 0.41 -0.39] [-0.12 0.31 -0.23] [ 0.17 -0.3 -0.11]]
When
n
smaller thanx.shape[axis]
>>> with jnp.printoptions(precision=2, suppress=True): ... print(jax.scipy.fft.idct(x, n=2)) [[ 1.12 -0.31] [ 0.04 -0.08] [ 0.05 -0.3 ]]
When
n
smaller thanx.shape[axis]
andaxis=0
>>> with jnp.printoptions(precision=2, suppress=True): ... print(jax.scipy.fft.idct(x, n=2, axis=0)) [[ 0.38 0.57 -0.45] [ 0.43 0.44 0.24]]
When
n
larger thanx.shape[axis]
andaxis=0
>>> with jnp.printoptions(precision=2, suppress=True): ... print(jax.scipy.fft.idct(x, n=4, axis=0)) [[ 0.1 0.38 -0.16] [ 0.28 0.18 -0.26] [ 0.3 0.15 -0.08] [ 0.13 0.3 0.29]]
jax.scipy.fft.idct
can be used to reconstructx
from the result ofjax.scipy.fft.dct
>>> x_dct = jax.scipy.fft.dct(x) >>> jnp.allclose(x, jax.scipy.fft.idct(x_dct)) Array(True, dtype=bool)