SignalProcessing - Maple Programming Help

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

SignalProcessing

 FFT
 compute forward fast Fourier transform
 InverseFFT
 compute inverse fast Fourier transform

 Calling Sequence FFT(A) FFT(A1, A2) InverseFFT(A) InverseFFT(A1, A2)

Parameters

 A - Array of complex numeric values; the signal A1, A2 - Arrays of real numeric values corresponding to the real and imaginary parts of the signal

Options

 • container     : Array or [Array, Array], predefined Array(s) for holding results
 • inplace       : truefalse, specifies that output should overwrite input
 • normalization : name, type of normalization
 • dimension     : integer or [integer] or all or "all"

Description

 • The FFT(A) command computes the fast Fourier transform (FFT) of the Array A and returns the result in an Array with datatype complex[8]. With two Array arguments, invoked as FFT(A1, A2), the command interprets A1 and A2 as giving the real and imaginary parts of the input signal, respectively, and returns the result as a sequence of two Arrays with datatype float[8]. These Arrays are the real and imaginary parts of the output signal. For this calling sequence, A1 and A2 must have the same number of elements.
 • The InverseFFT(A) command computes the inverse fast Fourier transform of the Array A and returns the result in an Array with datatype complex[8]. With two Array arguments, invoked as InverseFFT(A1, A2), the command interprets A1 and A2 as giving the real and imaginary parts of the input signal, respectively, and returns the result as a sequence of two Arrays with datatype float[8]. These Arrays are the real and imaginary parts of the output signal. For this calling sequence, A1 and A2 must have the same number of elements.
 • Before the code performing the computation runs, the input Array(s) are converted to datatype complex[8] (for the calling sequences with A) or float[8] (for the calling sequences with A1 and A2) if they do not have that datatype already. For this reason, it is most efficient if the input Array(s) have this datatype beforehand.
 • The number of elements of A must be a power of $2$ greater than $2$.  If you use FFT on a sample not satisfying this requirement, it will print a warning and use SignalProcessing:-DFT instead; similarly, if you use InverseFFT on such a sample, it will print a warning and use SignalProcessing:-InverseDFT.
 • The code underlying these commands (in the Intel Integrated Performance Primitives (IPP) library, see software.intel.com/en-us/intel-ipp) does not support Arrays of dimension two or higher directly. However, when called with such an Array, these commands call the FourierTransform or InverseFourierTransform commands in the DiscreteTransforms package instead, which supports Arrays with dimension at most 5. In this case, the container option cannot be used.
 For more information on Fourier transforms in Maple, including a summarized comparision of SignalProcessing[FFT], SignalProcessing[DFT], and DiscreteTransforms[FourierTransform], see Fourier Transforms in Maple.
 • The option normalization must be one of the following: none, symmetric or full. If normalization is none, then the FFT is computed without any normalization. If it is symmetric, then the transforms are computed using $\frac{1}{\sqrt{N}}$ as the multiplier for both the forward and inverse transforms. If it is full, then $\frac{1}{N}$ is used as the multiplier, where $N$ is the length of A.
 • If the container=C option is provided, and there is a single rtable argument A, then the results are put into C and C is returned.  In this case, the container C must be an Array having datatype complex[8] and size equal to that of A.

If the container = [C1, C2] option is provided, and there are two rtable arguments A1 and A2, then the results are put into C1 and C2 and they are returned. In this case, C1 and C2 must be Arrays having datatype float[8] and size equal to that of A1.

With this option, no additional memory is allocated to store the result.

 • If the inplace or inplace=true option is provided, then A or A1 and A2 are overwritten with the results. In this case, the container option is ignored. Furthermore, if A is specified, it must have datatype complex[8], and if A1 and A2 are specified, they must have datatype float[8].
 • The option dimension specifies the array dimension to be transformed. If dimension = all or dimension = "all" is provided, then the array is transformed in all dimensions. The default is all.

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

Examples

 > $\mathrm{with}\left(\mathrm{SignalProcessing}\right):$
 > $a≔\mathrm{GenerateTone}\left(8,1,\frac{1}{\mathrm{\pi }},\mathrm{\pi }\right):$
 > $b≔\mathrm{FFT}\left(a\right)$
 $\left[\begin{array}{cccccccc}-0.3133895291381244+0.0{}I& -0.3048683275277187-0.21785590664310955{}I& -0.23486185171591376-0.8316020780325695{}I& -0.5051225130415029+0.8410347860008229{}I& -0.4253322110377948+0.0{}I& -0.5051225130415029-0.8410347860008229{}I& -0.23486185171591376+0.8316020780325695{}I& -0.3048683275277187+0.21785590664310955{}I\end{array}\right]$ (6.1)
 > $c≔\mathrm{InverseFFT}\left(b\right)$
 $\left[\begin{array}{cccccccc}-0.9999999999999999-7.642294749548242{}{10}^{-18}{}I& 0.4161468364414224-2.7114567558987113{}{10}^{-17}{}I& 0.6536436213500372+7.642294749548242{}{10}^{-18}{}I& -0.9601702863236703+1.9249194552698347{}{10}^{-17}{}I& 0.14550003213097662-7.642294749548242{}{10}^{-18}{}I& 0.8390715302853515+1.5148897038037937{}{10}^{-17}{}I& -0.8438539572576524+7.642294749548242{}{10}^{-18}{}I& -0.1367372214521727-7.283524031749171{}{10}^{-18}{}I\end{array}\right]$ (6.2)
 > $\mathrm{Norm}\left(\mathrm{map}\left(\mathrm{fnormal},a-c\right)\right)$
 ${0.}$ (6.3)
 > $b≔\mathrm{FFT}\left(a,'\mathrm{normalization}'='\mathrm{full}'\right)$
 $\left[\begin{array}{cccccccc}-0.11079993060321347+0.0{}I& -0.10778723088192568-0.0770236944544431{}I& -0.083036203995176-0.29401573431282724{}I& -0.1785877771508185+0.29735070019747933{}I& -0.15037764534094622+0.0{}I& -0.1785877771508185-0.29735070019747933{}I& -0.083036203995176+0.29401573431282724{}I& -0.10778723088192568+0.0770236944544431{}I\end{array}\right]$ (6.4)
 > $c≔\mathrm{InverseFFT}\left(b,'\mathrm{normalization}'='\mathrm{full}'\right)$
 $\left[\begin{array}{cccccccc}-0.125+0.0{}I& 0.05201835455517782-1.8819707062066693{}{10}^{-19}{}I& 0.08170545266875465+0.0{}I& -0.12002128579045881+1.6582949115279699{}{10}^{-18}{}I& 0.018187504016372084+0.0{}I& 0.10488394128566898+1.8819707062066693{}{10}^{-19}{}I& -0.10548174465720658+0.0{}I& -0.017092152681521616-1.6582949115279699{}{10}^{-18}{}I\end{array}\right]$ (6.5)
 > $\mathrm{Norm}\left(\mathrm{map}\left(\mathrm{fnormal},a-c\right)\right)$
 ${0.875000000000000000}$ (6.6)
 > A := Array( 1 .. 1024, proc( n )        local s := 0;        local m := n;        while m <> 0 do            s := s + irem( m, 10, 'm' )^2        end end, 'datatype' = 'float'[ 8 ] ):
 > $U≔\mathrm{FFT}\left(A\right):$
 > $\mathbf{use}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{plots}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{display}\left(⟨⟨⟨\mathrm{listplot}\left(A\right)⟩,⟨\mathrm{listplot}\left(\mathrm{map}\left(\mathrm{ℜ},{U}_{1..512}\right)\right)⟩,\mathrm{listplot}\left(\mathrm{map}\left(\mathrm{ℑ},{U}_{1..512}\right)\right)⟩⟩\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end use}$

We can also use the other calling sequence, to get the real and imaginary parts split. In this case, we have to explicitly specify the imaginary part of the input as 0.

 > $\mathrm{zeros}≔\mathrm{Array}\left(1..1024,'\mathrm{datatype}'='\mathrm{float}'\left[8\right]\right):$
 > $\mathrm{U1},\mathrm{U2}≔\mathrm{FFT}\left(A,\mathrm{zeros}\right):$
 > $\mathbf{use}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{plots}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{display}\left(⟨⟨⟨\mathrm{listplot}\left(A\right)⟩,⟨\mathrm{listplot}\left({\mathrm{U1}}_{1..512}\right)⟩,\mathrm{listplot}\left({\mathrm{U2}}_{1..512}\right)⟩⟩\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end use}$

 > $\mathrm{with}\left(\mathrm{ImageTools}\right):$
 > $\mathrm{img}≔\mathrm{Read}\left(\mathrm{cat}\left(\mathrm{kernelopts}\left(\mathrm{datadir}\right),"/images/phone.jpg"\right)\right)$
 ${{\mathrm{_rtable}}}_{{18446883798044584886}}$ (6.7)
 > $\mathrm{Embed}\left(\mathrm{Create}\left(\mathrm{img}\right)\right)$

 > $m≔\mathrm{FFT}\left(\mathrm{img}\right):$
 > $\mathrm{InverseFFT}\left(m\right)$
 ${{\mathrm{_rtable}}}_{{18446883798044573318}}$ (6.8)
 > $\mathrm{m2}≔\mathrm{PowerSpectrum}\left(m\right):$
 > $\mathrm{Embed}\left(\mathrm{Create}\left(\mathrm{m2}\right)\right)$

 > $\mathrm{m3}≔\mathrm{FFTShift}\left(\mathrm{m2}\right):$
 > $\mathrm{Embed}\left(\mathrm{Create}\left(\mathrm{m3}\right)\right)$

 > 

Compatibility

 • The SignalProcessing[FFT] and SignalProcessing[InverseFFT] commands were introduced in Maple 17.