DCT - Maple Help

SignalProcessing

 DCT
 compute forward discrete cosine transform
 InverseDCT
 compute inverse discrete cosine transform

 Calling Sequence DCT(A) InverseDCT(A)

Parameters

 A - Array of real numeric values; the signal

Options

 • container : Array, predefined Array for holding results
 • inplace   : truefalse, specifies that output should overwrite input

Description

 • The DCT(A) command computes the discrete cosine transform (DCT) of the Array A and returns the result in an Array with datatype float[8].
 • The InverseDCT(A) command computes the inverse discrete cosine transform of the Array A and returns the result in an Array with datatype float[8].
 • Before the code performing the computation runs, A is converted to datatype float[8] if it does not have that datatype already. For this reason, it is most efficient if A has this datatype beforehand.
 • The discrete cosine transform B of a sample of $N$ elements with initial index 1 is defined by the formula

${B}_{k}={C}_{k}\left({\sum }_{i=1}^{N}{A}_{i}\mathrm{cos}\left(\frac{\left(2i-1\right)\mathrm{\pi }\left(k-1\right)}{2N}\right)\right)$

 where ${C}_{k}$ is given by

${C}_{k}=\left\{\begin{array}{cc}\frac{1}{\sqrt{N}}& k=1\\ \sqrt{\frac{2}{N}}& \mathrm{otherwise}\end{array}\right\$

 • Samples may be of arbitrary length, but when the length is a power of $2$, a faster algorithm is used,
 • If the container=C option is provided, then the results are put into C and C is returned. With this option, no additional memory is allocated to store the result. The container must be an Array having datatype float[8] and size equal to those of A.
 • If the inplace or inplace=true option is provided, then A is overwritten with the results. In this case, the container option is ignored. Furthermore, A must have datatype float[8].

 • The SignalProcessing[DCT] and SignalProcessing[InverseDCT] commands are thread-safe as of Maple 17.

Examples

 > $\mathrm{with}\left(\mathrm{SignalProcessing}\right):$
 > $\mathrm{with}\left(\mathrm{plots}\right):$
 > $N≔10:$
 > $A≔\mathrm{GenerateTone}\left(N,1,0.1,0\right)+\mathrm{GenerateTone}\left(N,3,0.4,0.2\right):$
 > $B≔\mathrm{DCT}\left(A\right)$
 ${B}{≔}\left[\right]$ (1)
 > $\mathrm{display}\left(⟨⟨⟨\mathrm{listplot}\left(A,'\mathrm{title}'="Signal"\right)⟩,⟨\mathrm{listplot}\left(B,'\mathrm{title}'="Cosine Transform"\right)⟩⟩⟩\right)$

 > $C≔\mathrm{InverseDCT}\left(B\right)$
 ${C}{≔}\left[\right]$ (2)
 > $\mathrm{map}\left(\mathrm{fnormal},A-C\right)$
 $\left[\right]$ (3)
 > $A≔\mathrm{GenerateJaehne}\left(10,3\right)$
 ${A}{≔}\left[\right]$ (4)
 > $C≔\mathrm{Array}\left(1..10,'\mathrm{datatype}'='\mathrm{float}'\left[8\right]\right):$
 > $\mathrm{DCT}\left(A,'\mathrm{container}'=C\right)$
 $\left[\right]$ (5)
 > $C$
 $\left[\right]$ (6)
 > $\mathrm{InverseDCT}\left(C,'\mathrm{inplace}'\right)$
 $\left[\right]$ (7)
 > $C$
 $\left[\right]$ (8)
 > $\mathrm{map}\left(\mathrm{fnormal},A-C\right)$
 $\left[\right]$ (9)

Compatibility

 • The SignalProcessing[DCT] and SignalProcessing[InverseDCT] commands were introduced in Maple 17.