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 is None, which is equivalent to "backward".

Returns:

array containing the inverse discrete cosine transform of x

Return type:

Array

See also

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.02 -0.   -0.17]
 [-0.02 -0.07 -0.28]
 [-0.16 -0.36  0.18]]

When n smaller than x.shape[axis]

>>> with jnp.printoptions(precision=2, suppress=True):
...    print(jax.scipy.fft.idct(x, n=2))
[[ 0.   -0.19]
 [-0.03 -0.34]
 [-0.38  0.04]]

When n smaller than x.shape[axis] and axis=0

>>> with jnp.printoptions(precision=2, suppress=True):
...    print(jax.scipy.fft.idct(x, n=2, axis=0))
[[-0.35  0.23 -0.1 ]
 [ 0.17 -0.09  0.01]]

When n larger than x.shape[axis] and axis=0

>>> with jnp.printoptions(precision=2, suppress=True):
...    print(jax.scipy.fft.idct(x, n=4, axis=0))
[[-0.34  0.03  0.07]
 [ 0.    0.18 -0.17]
 [ 0.14  0.09 -0.14]
 [ 0.   -0.18  0.14]]

jax.scipy.fft.idct can be used to reconstruct x from the result of jax.scipy.fft.dct

>>> x_dct = jax.scipy.fft.dct(x)
>>> jnp.allclose(x, jax.scipy.fft.idct(x_dct))
Array(True, dtype=bool)