 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.
 • The InverseDCT(A) command computes the inverse discrete cosine transform of the Array A and returns the result in an Array with datatype float.
 • Before the code performing the computation runs, A is converted to datatype float 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 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. • 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)$
 $\left[\begin{array}{cccccccccc}-8.426000324584082{}{10}^{-16}& 1.8408150749374694& 2.1266270208801& 1.0734052263252103& -5.736608702197509{}{10}^{-16}& 1.8674493435445685& -1.7948614201002696{}{10}^{-15}& 4.532017760897826& 3.29911475027503& -2.4547807280412366\end{array}\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)$
 $\left[\begin{array}{cccccccccc}3.940199733523725& -1.9199792650748935& 1.784425963812391& 0.032717405218654294& -2.8373638374798795& 1.9401997335237255& -3.5380132538247864& 1.166391975062493& 0.6507513939685532& -1.2193298487299857\end{array}\right]$ (2)
 > $\mathrm{map}\left(\mathrm{fnormal},A-C\right)$
 $\left[\begin{array}{cccccccccc}0.& 0.& 0.& 0.& 0.& 0.& -0.& 0.& 0.& 0.\end{array}\right]$ (3)
 > $A≔\mathrm{GenerateJaehne}\left(10,3\right)$
 $\left[\begin{array}{cccccccccc}0.0& 0.46930339512069263& 1.7633557568774194& 2.9630650217854133& 1.7633557568774196& -2.1213203435596424& -1.76335575687742& 2.963065021785413& -1.7633557568774183& 0.46930339512069374\end{array}\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[\begin{array}{cccccccccc}1.5000000000000004& 1.534351019701625& -0.3036659479510252& -2.5278309009474733& -2.0603989756276833& 2.2480137296073375& 1.2781204298267193& -2.6781162095883118& 2.163239928271285& -1.0329588850112363\end{array}\right]$ (5)
 > $C$
 $\left[\begin{array}{cccccccccc}1.5000000000000004& 1.534351019701625& -0.3036659479510252& -2.5278309009474733& -2.0603989756276833& 2.2480137296073375& 1.2781204298267193& -2.6781162095883118& 2.163239928271285& -1.0329588850112363\end{array}\right]$ (6)
 > $\mathrm{InverseDCT}\left(C,'\mathrm{inplace}'\right)$
 $\left[\begin{array}{cccccccccc}-1.3877787807814457{}{10}^{-16}& 0.46930339512069275& 1.7633557568774196& 2.963065021785413& 1.7633557568774196& -2.1213203435596424& -1.76335575687742& 2.9630650217854124& -1.7633557568774183& 0.46930339512069374\end{array}\right]$ (7)
 > $C$
 $\left[\begin{array}{cccccccccc}-1.3877787807814457{}{10}^{-16}& 0.46930339512069275& 1.7633557568774196& 2.963065021785413& 1.7633557568774196& -2.1213203435596424& -1.76335575687742& 2.9630650217854124& -1.7633557568774183& 0.46930339512069374\end{array}\right]$ (8)
 > $\mathrm{map}\left(\mathrm{fnormal},A-C\right)$
 $\left[\begin{array}{cccccccccc}0.& -0.& -0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\end{array}\right]$ (9)
 > Compatibility

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