jax.scipy.fft.idct#

jax.scipy.fft.idct(x, type=2, n=None, axis=-1, norm=None)[原始碼]#

計算輸入的反離散餘弦變換

JAX 實現的 scipy.fft.idct()

參數:
  • x (Array) – 陣列

  • type (int) – 整數,預設值 = 2。目前僅支援 type 2。

  • n (int | None | None) – 整數,預設值 = x.shape[axis]。轉換的長度。如果大於 x.shape[axis],輸入將會補零;如果小於,輸入將會被截斷。

  • axis (int) – 整數,預設值=-1。執行 dct 的軸。

  • norm (str | None | None) – 字串。正規化模式:[None, "backward", "ortho"] 其中之一。預設值為 None,相當於 "backward"

返回:

包含 x 的反離散餘弦變換的陣列

返回類型:

Array

參見

範例

>>> 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]]

n 小於 x.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 ]]

n 小於 x.shape[axis]axis=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]]

n 大於 x.shape[axis]axis=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 可用於從 jax.scipy.fft.dct 的結果重建 x

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