FFT - Maple Help

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 or list of complex numeric values; the signal A1, A2 - Arrays or lists 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"
 • size : posint, keyword same or recommended, or list of any of these, specifies the final size of the signal containers

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.
 • It is recommended that the number of elements of A be a power of $2$ greater than $2$.  If you use FFT on a sample not satisfying this requirement, it will use SignalProcessing:-DFT instead; similarly, if you use InverseFFT on such a sample, it will 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 option size is used to tell Maple to use either padded or truncated versions of the data container(s). Padding is helpful due to the increase in both the speed of computation and the frequency resolution.
 • Suppose the input is one-dimensional of size N. If size = same, which is the default, then the size of the input will remain the same. If size = recommended and N is not a power of 2, then the size of the input will be increased to the smallest power of 2 larger than N. (If size = recommended and N is already a power of 2, then the size will not change.) If size is a positive integer M, then the size of the input will either be truncated or padded with zeros so that the final size is M.
 • Suppose the input is multi-dimensional. If size is a list, then each element is applied to the corresponding dimension as specified in the dimension option. If size is not a list, then the value applies to each dimension as specified in the dimension option. Note that any given dimension can only be resized at most once.
 • If inplace = true, then the input will be padded or truncated in-place. Note that a multi-dimensional input cannot be truncated in-place.
 • If the container option is provided, any storage rtable must have the same size as the padded/truncated version of the input.
 • The subtype and starting indices of the output of the FFT and InverseFFT commands are the same as the input. For example, if A is a row Vector, then FFT(A) is a row Vector, and if B is an Array with starting indices 0, then FFT(B) is an Array with starting indices 0.

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

Examples

 > $\mathrm{with}\left(\mathrm{SignalProcessing}\right):$

Example

 > $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.3048683275277182-0.21785590664310944{}I& -0.23486185171591406-0.8316020780325692{}I& -0.5051225130415028+0.8410347860008234{}I& -0.42533221103779534+0.0{}I& -0.5051225130415028-0.8410347860008234{}I& -0.23486185171591406+0.8316020780325692{}I& -0.3048683275277182+0.21785590664310944{}I\end{array}\right]$ (6.1.1)
 > $c≔\mathrm{InverseFFT}\left(b\right)$
 $\left[\begin{array}{cccccccc}-0.9999999999999998+1.5351176953382677{}{10}^{-17}{}I& 0.4161468364414225+2.0964557761846127{}{10}^{-17}{}I& 0.6536436213500375-1.5351176953382677{}{10}^{-17}{}I& -0.9601702863236704+2.701484747157252{}{10}^{-18}{}I& 0.14550003213097584+1.5351176953382677{}{10}^{-17}{}I& 0.8390715302853518-2.6773336426783047{}{10}^{-17}{}I& -0.8438539572576528-1.5351176953382677{}{10}^{-17}{}I& -0.13673722145217193+3.1072939177796674{}{10}^{-18}{}I\end{array}\right]$ (6.1.2)
 > $\mathrm{Norm}\left(\mathrm{map}\left(\mathrm{fnormal},a-c\right)\right)$
 ${0.}$ (6.1.3)
 > $b≔\mathrm{FFT}\left(a,'\mathrm{normalization}'='\mathrm{full}'\right)$
 $\left[\begin{array}{cccccccc}-0.11079993060321347+0.0{}I& -0.10778723088192549-0.07702369445444306{}I& -0.0830362039951761-0.2940157343128271{}I& -0.17858777715081847+0.2973507001974795{}I& -0.15037764534094644+0.0{}I& -0.17858777715081847-0.2973507001974795{}I& -0.0830362039951761+0.2940157343128271{}I& -0.10778723088192549+0.07702369445444306{}I\end{array}\right]$ (6.1.4)
 > $c≔\mathrm{InverseFFT}\left(b,'\mathrm{normalization}'='\mathrm{full}'\right)$
 $\left[\begin{array}{cccccccc}-0.125+0.0{}I& 0.05201835455517782+5.303489200959247{}{10}^{-19}{}I& 0.08170545266875467+0.0{}I& -0.12002128579045881-2.536307316390097{}{10}^{-20}{}I& 0.01818750401637198+0.0{}I& 0.10488394128566898-5.303489200959247{}{10}^{-19}{}I& -0.10548174465720661+0.0{}I& -0.017092152681521505+2.536307316390097{}{10}^{-20}{}I\end{array}\right]$ (6.1.5)
 > $\mathrm{Norm}\left(\mathrm{map}\left(\mathrm{fnormal},a-c\right)\right)$
 ${0.875000000000000000}$ (6.1.6)

Example

 > 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}'}_{8}\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{Embed}\left(\mathrm{Create}\left(\mathrm{img}\right)\right)$

 > $m≔\mathrm{FFT}\left(\mathrm{img}\right):$
 > $\mathrm{InverseFFT}\left(m\right)$
 > $\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)$

Example

 > $A≔\mathrm{Vector}\left(\left[1,2-I,3\right],'\mathrm{datatype}'='{\mathrm{complex}}_{8}'\right)$
 $\left[\begin{array}{c}1.0+0.0{}I\\ 2.0-1.0{}I\\ 3.0+0.0{}I\end{array}\right]$ (6.3.1)
 > $\mathrm{FFT}\left(A,'\mathrm{size}'='\mathrm{same}'\right)$
 $\left[\begin{array}{c}3.4641016151377553-0.5773502691896258{}I\\ -1.3660254037844386+0.788675134594813{}I\\ -0.3660254037844387-0.2113248654051871{}I\end{array}\right]$ (6.3.2)
 > $\mathrm{FFT}\left(A,'\mathrm{size}'='\mathrm{recommended}'\right)$
 $\left[\begin{array}{c}3.0-0.5{}I\\ -1.5-1.0{}I\\ 1.0+0.5{}I\\ -0.5+1.0{}I\end{array}\right]$ (6.3.3)
 > $\mathrm{FFT}\left(A,'\mathrm{size}'=5\right)$
 $\left[\begin{array}{c}2.6832815729997477-0.4472135954999579{}I\\ -0.7871288030510093-1.7774440776557507{}I\\ -0.12466895493455622+1.1120484992839155{}I\\ 0.4010621571845775-0.38844170153393665{}I\\ 0.06352200530103065+1.5010508754057297{}I\end{array}\right]$ (6.3.4)

Example

 > $X≔\mathrm{Array}\left(\left[\left[\left[0.904722238067363,0.721227498581740,0.488897743920167,0.507858284661118,0.904880968679893,0.587044704531417,0.446783749429806\right],\left[0.744074260367462,0.335356839962797,0.546805718738968,0.296675873218327,0.923379642103244,0.875942811492984,0.775712678608402\right],\left[0.698745832334794,0.796183873585212,0.237283579771521,0.711215780433683,0.227664297816554,0.532825588799455,0.780227435151377\right],\left[0.903720560556316,0.0377388662395521,0.730330862855453,0.594896074008614,0.194764289567049,0.644318130193692,0.183511155737270\right],\left[0.494173936639270,0.395515215668593,0.801014622769739,0.111119223440599,0.470923348517591,0.510771564172110,0.744692807074156\right]\right],\left[\left[0.479922141146060,0.136553137355370,0.231594386708524,0.424166759713807,0.184816320124136,0.622475086001227,0.435858588580919\right],\left[0.0305409463046367,0.261871183870716,0.963088539286913,0.117417650855806,0.311102286650413,0.939001561999887,0.929385970968730\right],\left[0.334163052737496,0.913286827639239,0.578525061023439,0.602843089382083,0.170708047147859,0.811580458282477,0.625618560729690\right],\left[0.715037078400694,0.987982003161633,0.928854139478045,0.408719846112552,0.844308792695389,0.794831416883453,0.686775433365315\right],\left[0.653757348668560,0.679135540865748,0.262482234698333,0.438869973126103,0.301246330279491,0.508508655381127,0.296320805607773\right]\right],\left[\left[0.500022435590201,0.679727951377338,0.521135830804001,0.318778301925882,0.430207391329584,0.550156342898422,0.486791632403172\right],\left[0.197809826685929,0.0987122786555743,0.458848828179931,0.221746734017240,0.435698684103899,0.350727103576883,0.0811257688657853\right],\left[0.890922504330789,0.885168008202475,0.488608973803579,0.262211747780845,0.225921780972399,0.378609382660268,0.368484596490336\right],\left[0.779051723231275,0.367436648544477,0.0292202775621463,0.258064695912067,0.230488160211558,0.817627708322262,0.188955015032545\right],\left[0.106761861607241,0.624060088173690,0.0855157970900440,0.979748378356085,0.207742292733028,0.306349472016557,0.547008892286345\right]\right]\right]\right)$
 > $\mathrm{Y1}≔\mathrm{FFT}\left(X,'\mathrm{dimension}'=\left[1,-1\right]\right)$
 > $\mathrm{Y2}≔\mathrm{FFT}\left(X,'\mathrm{size}'='\mathrm{recommended}','\mathrm{dimension}'=\left[1,-1\right]\right)$
 > $\mathrm{Y3}≔\mathrm{FFT}\left(X,'\mathrm{size}'=\left[4,8\right],'\mathrm{dimension}'=\left[1,-1\right]\right)$

Compatibility

 • The SignalProcessing:-FFT and SignalProcessing:-InverseFFT commands were introduced in Maple 17.