SignalProcessing - Maple Programming Help

Home : Support : Online Help : Science and Engineering : Signal Processing : Transforms : SignalProcessing/DCT

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   : boolean, 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 is defined by the formula

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

 where $C$ is given by

$C\left(k\right)=\left\{\begin{array}{cc}\frac{1}{\sqrt{N}}& k=0\\ \frac{\sqrt{2}}{\sqrt{N}}& 0

 .
 • 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[\begin{array}{cccccccccc}{-}{8.42600032458408}{}{{10}}^{{-16}}& {1.84081507493747}& {2.12662702088010}& {1.07340522632521}& {-}{5.95808196779346}{}{{10}}^{{-16}}& {1.86744934354457}& {-}{1.78742459033804}{}{{10}}^{{-15}}& {4.53201776089783}& {3.29911475027503}& {-}{2.45478072804124}\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)$
 ${C}{≔}\left[\begin{array}{cccccccccc}{3.94019973352373}& {-}{1.91997926507489}& {1.78442596381239}& {0.0327174052186538}& {-}{2.83736383747988}& {1.94019973352373}& {-}{3.53801325382479}& {1.16639197506249}& {0.650751393968553}& {-}{1.21932984872999}\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)$
 ${A}{≔}\left[\begin{array}{cccccccccc}{0.}& {0.469303395120693}& {1.76335575687742}& {2.96306502178541}& {1.76335575687742}& {-}{2.12132034355964}& {-}{1.76335575687742}& {2.96306502178541}& {-}{1.76335575687742}& {0.469303395120694}\end{array}\right]$ (4)
 > $C≔\mathrm{Array}\left(1..10,'\mathrm{datatype}'={'\mathrm{float}'}_{8}\right):$
 > $\mathrm{DCT}\left(A,'\mathrm{container}'=C\right)$
 $\left[\begin{array}{cccccccccc}{1.50000000000000}& {1.53435101970163}& {-}{0.303665947951025}& {-}{2.52783090094747}& {-}{2.06039897562768}& {2.24801372960734}& {1.27812042982672}& {-}{2.67811620958831}& {2.16323992827129}& {-}{1.03295888501124}\end{array}\right]$ (5)
 > $C$
 $\left[\begin{array}{cccccccccc}{1.50000000000000}& {1.53435101970163}& {-}{0.303665947951025}& {-}{2.52783090094747}& {-}{2.06039897562768}& {2.24801372960734}& {1.27812042982672}& {-}{2.67811620958831}& {2.16323992827129}& {-}{1.03295888501124}\end{array}\right]$ (6)
 > $\mathrm{InverseDCT}\left(C,'\mathrm{inplace}'\right)$
 $\left[\begin{array}{cccccccccc}{2.77555756156289}{}{{10}}^{{-17}}& {0.469303395120693}& {1.76335575687742}& {2.96306502178541}& {1.76335575687742}& {-}{2.12132034355964}& {-}{1.76335575687742}& {2.96306502178541}& {-}{1.76335575687742}& {0.469303395120694}\end{array}\right]$ (7)
 > $C$
 $\left[\begin{array}{cccccccccc}{2.77555756156289}{}{{10}}^{{-17}}& {0.469303395120693}& {1.76335575687742}& {2.96306502178541}& {1.76335575687742}& {-}{2.12132034355964}& {-}{1.76335575687742}& {2.96306502178541}& {-}{1.76335575687742}& {0.469303395120694}\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.