dct#

diffsptk.DCT#

alias of DiscreteCosineTransform

class diffsptk.DiscreteCosineTransform(dct_length: int, dct_type: int = 2)[source]#

See this page for details.

Parameters:
dct_lengthint >= 1

The DCT length, \(L\).

dct_typeint in [1, 4]

The DCT type.

forward(x: Tensor) Tensor[source]#

Apply DCT to the input.

Parameters:
xTensor [shape=(…, L)]

The input.

Returns:
outTensor [shape=(…, L)]

The DCT output.

Examples

>>> x = diffsptk.ramp(3)
>>> dct = diffsptk.DCT(4)
>>> y = dct(x)
>>> y
tensor([ 3.0000, -2.2304,  0.0000, -0.1585])
diffsptk.functional.dct(x: Tensor, dct_type: int = 2) Tensor[source]#

Compute DCT.

Parameters:
xTensor [shape=(…, L)]

The input.

dct_typeint in [1, 4]

The DCT type.

Returns:
outTensor [shape=(…, L)]

The DCT output.

See also

idct