Digital Signal Processing (ECN-312)
Lecture 6 (Convolution using DFT)
Dheeraj Kumar
[email protected]
February 6, 2023
Table of Contents
1 Circular convolution
2 Linear convolution using DFT
3 Implementing linear time-invariant (LTI) systems using the DFT
2 / 38
Table of Contents
1 Circular convolution
2 Linear convolution using DFT
3 Implementing linear time-invariant (LTI) systems using the DFT
3 / 38
Circular convolution
❑ Consider two finite-duration sequences x1 [n] and x2 [n], both of
length N
DF T
❑ x1 [n] ←→ X1 [k ]
DF T
❑ x2 [n] ←→ X2 [k ]
DF T
❑ We aim to determine sequence x3 [n] ←→ X3 [k ] = X1 [k ]X2 [k ]
❑ Using the property of periodic convolution from DFS coefficients
PN−1 DF S
❑ x̃3 [n] = m=0 x̃1 [m]x̃2 [n − m] ←→ X̃1 [k ]X̃2 [k ] = X̃3 [k ]
❑ x3 [n] corresponds to one period of x̃3 [n] (i.e., for 0 ≤ n ≤ N − 1)
4 / 38
Circular convolution
N−1
X N−1
X
x3 [n] = x̃1 [m]x̃2 [n − m] = x1 [((m))N ]x2 [((n − m))N ]
m=0 m=0
N−1
X
= x1 [m]x2 [((n − m))N ]
m=0
Since X1 [k ]X2 [k ] =
= x1 [n]⃝x
N 2 [n] = x2 [n]⃝x
N 1 [n]
X2 [k ]X1 [k ]
N−1
X
= x2 [m]x1 [((n − m))N ]
m=0
❑ The second sequence x2 [((n − m))N ] is circularly time reversed
and circularly shifted with respect to the first
❑ This operation is called “circular convolution”
❑ More specifically, N-point circular convolution
5 / 38
Example: circular convolution with a delayed
impulse sequence
0,
0 ≤ n < n0
❑ Let x1 [n] = δ[n − n0 ] = 1, n = n0
0, n0 < n ≤ N − 1
❑ Where, 0 < n0 < N
❑ x2 [n] be an arbitrary sequence of length N
❑ N = 5 and x1 [n] = δ[n − n0 ] for n0 = 1
6 / 38
Example: circular convolution with a delayed
impulse sequence
❑ x3 [n] is the sequence x2 [n] rotated to the right by n0 samples in
the interval 0 ≤ n ≤ N − 1
DF T
❑ x1 [n] ←→ X1 [k ] = WNkn0 → X3 [k ] = WNkn0 X2 [k ]
7 / 38
Example: circular convolution of two rectangular
pulses
(
1, 0 ≤ n ≤ L − 1
❑ Let x1 [n] = x2 [n] =
0, L ≤ n ≤ N − 1
❑ If L = N, the N-point DFTs are:(
N, k = 0
X1 [k ] = X2 [k ] = N−1 kn
P
n=0 WN =
0, otherwise
(
N 2, k = 0
❑ X3 [k ] = X1 [k ]X2 [k ] =
0, otherwise
❑ → x3 [n] = N, 0 ≤ n ≤ N − 1
8 / 38
Example: circular convolution of two rectangular
pulses
1−WNLk
❑ If N = 2L, the N-point DFTs are: X1 [k ] = X2 [k ] = 1−WNk
!2
1−WNLk
❑ DFT of triangular-shaped sequence x3 [n] is X3 [k ] = 1−WNk
9 / 38
Circular convolution and duality
DF T
❑ x1 [n]⃝x
N 2 [n] ←→ X1 [k ]X2 [k ]
DF T 1 1 PN−1
❑ x1 [n]x2 [n] ←→ N X1 [k ]⃝X2 [k ]
N = N l=0 X1 [l]X2 [((k − l))N ]
10 / 38
Table of Contents
1 Circular convolution
2 Linear convolution using DFT
3 Implementing linear time-invariant (LTI) systems using the DFT
11 / 38
How to compute linear convolution using DFT
1. Compute the N-point DFT X1 [k ] and X2 [k ] of the two sequences
x1 [n] and x2 [n] respectively
2. Compute the product X3 [k ] = X1 [k ]X2 [k ] for 0 ≤ k ≤ N − 1
3. Compute the sequence x3 [n] = x1 [n]⃝x
N 2 [n] as the inverse DFT of
X3 [k ]
❑ To obtain a linear convolution x1 [n] ∗ x2 [n], we must ensure that
circular convolution has the effect of linear convolution
❑ By manipulating N
❑ But, why to use this procedure to obtain linear convolution?
❑ Why not directly compute using expression of linear convolution
❑ Efficient algorithms are available for computing DFT of a
finite-duration sequence
❑ Collectively as fast Fourier transform (FFT) algorithms
12 / 38
Linear convolution of two finite-length sequences
❑ Consider a sequence x1 [n] of length L and a sequence x2 [n] of
length P
❑ x3 [n] = x1 [n] ∗ x2 [n] = ∞
P
m=−∞ x1 [m]x2 [n − m]
❑ x3 [n] may be non-zero only for 0 ≤ n ≤ L + P − 2
❑ For all other values of n it would be zero
❑ Maximum length of x3 [n] is L + P − 1
13 / 38
Circular convolution as linear convolution with
aliasing
❑ A circular convolution of two finite-length sequences may be same
as the linear convolution
❑ Circular convolution calculated using N-point DFTs of the two
sequences
❑ Depends on the length of the DFT (N) in relation to the length of the
finite-length sequences (L, P)
❑ Relationship between circular convolution and linear convolution
can be interpreted in terms of time aliasing
14 / 38
Circular convolution as linear convolution with
aliasing
❑ Let sequence x[n] has a Fourier transform X (ejω )
❑ Samples of X (ejω ) at frequencies ωk = 2πk N corresponds to the
DFS coefficients of the periodic sequence x̃[n] = ∞
P
r =−∞ x[n − rN]
(
x̃[n], 0 ≤ n ≤ N − 1
❑ One period of x̃[n], i.e., xp [n] = has DFT
0, otherwise
2πk
(
X (ej N ), 0 ≤ k ≤ N − 1
X [k ] =
0, otherwise
❑ If x[n] has length less than or equal to N, no time aliasing occurs
and xp [n] = x[n]
❑ If the length of x[n] is greater than N, xp [n] may not be equal to
x[n] for some or all values of n
15 / 38
Circular convolution as linear convolution with
aliasing
P∞
❑ For x3 [n] = x1 [n] ∗ x2 [n] = m=−∞ x1 [m]x2 [n − m]
jω jω jω
❑ X3 (e ) = X1 (e )X2 (e )
❑ N-point DFT of x3 [n]:
2πk 2πk 2πk
❑ X3 [k ] = X3 (ej N ) = X1 (ej N )X2 (ej N ) = X1 [k ]X2 [k ], 0 ≤ k ≤ N − 1
❑ Sequence resulting as the inverse DFT of X3 [k ] is:
(P
∞
r =−∞x3 [n − rN], 0 ≤ n ≤ N − 1
❑ x3p [n] = = x1 [n]⃝x
N 2 [n]
0, otherwise
❑ Circular convolution of two finite-length sequences is equivalent to
their linear convolution, followed by time aliasing
16 / 38
Circular convolution as linear convolution with
aliasing
❑ If N ≥ L → X1 [k ] represents x1 [n] exactly
❑ If N ≥ P → X2 [k ] represents x2 [n] exactly
❑ x3p [n] = x3 [n] for all n only if N ≥ length of the sequence x3 [n]
❑ Maximum length of x3 [n] is L + P − 1
❑ Circular convolution corresponding to X1 [k ]X2 [k ] is identical to the
linear convolution corresponding to X1 (ejω )X2 (ejω ) if
N ≥L+P −1
17 / 38
Example: Linear convolution of two rectangular
pulses
( (
1, 0≤n ≤L−1 1, 0 ≤ n ≤ P − 1
❑ Let x1 [n] = and x2 [n] =
0, otherwise 0, otherwise
❑ L=P=6
18 / 38
Example: Linear convolution of two rectangular
pulses
❑ Let x3 [n] = x1 [n] ∗ x2 [n]
❑ Length of x3 [n] is L + P − 1 = 11
❑ Has the triangular shape
19 / 38
Example: Linear convolution of two rectangular
pulses
❑ Two shifted versions x3 [n + rN]
❑ Specifically, x3 [n − N] and x3 [n + N] for N = 6
20 / 38
Example: Linear convolution of two rectangular
pulses
❑ N-point circular convolution of x1 [n] and x2 [n]
❑ For N = L = 6
❑ Both x3 [n] and x3 [n + N] contribute to the result
❑ For N = 2L = 12
❑ Only x3 [n] contribute to the result
❑ Circular convolution = linear convolution
21 / 38
Example: Linear convolution of two sequences of
different lengths
❑ Consider two finite-duration sequences: x1 [n] of length L and x2 [n]
of length P, where P < L
❑ x3 [n] = x1 [n] ∗ x2 [n] is a finite-length sequence of length L + P − 1
22 / 38
Example: Linear convolution of two sequences of
different lengths
❑ L-point circular
(
convolution:
P∞
x1 [n]⃝x
L 2 [n] =
r =−∞ x3 [n − rL], 0 ≤ n ≤ L − 1
❑ x3p [n] =
0, otherwise
❑ For 0 ≤ n ≤ L − 1, x3p [n] is influenced only by x3 [n] and x3 [n + L]
23 / 38
Example: Linear convolution of two sequences of
different lengths
❑ For P < L only the term x3 [n + L] will alias into the interval
0≤n ≤L−1
❑ Last P − 1 points of x3 [n + L] (extending from n = 0 to n = P − 2),
will be added to the first P − 1 points of x3 [n]
❑ Last P − 1 points of x3 [n] extending from n = L to n = L + P − 2 will
be discarded
❑ Since the last P − 1 points of x3 [n + L] and the last P − 1 points of
x3 [n] are identical
❑ Take the P − 1 values of x3 [n] from n = L to L + P − 2 and add them
to the first P − 1 values of x3 [n]
❑ Remaining points from n = P − 1 to L − 1 (i.e., the last L − P + 1
points) are not corrupted
24 / 38
Example: Linear convolution of two sequences of
different lengths
❑ Here, P = 4 and L = 8
25 / 38
Example: Linear convolution of two sequences of
different lengths
❑ If the circular convolution is of sufficient length relative to the
lengths of the sequences x1 [n] and x2 [n]
❑ Aliasing with nonzero values can be avoided
❑ N ≥L+P −1
❑ Circular convolution and linear convolution will be identical
26 / 38
Table of Contents
1 Circular convolution
2 Linear convolution using DFT
3 Implementing linear time-invariant (LTI) systems using the DFT
27 / 38
Output of an LTI system for finite-length input
❑ Linear time-invariant systems can be implemented using
convolution
❑ → Circular convolution (implemented using DFT) can be used to
implement these systems
❑ Consider an L-point input sequence x[n] and a P-point impulse
response h[n]
❑ Output sequence, y [n] = x[n] ∗ h[n] is of finite duration with length
L+P −1
❑ For the circular convolution and linear convolution to be identical:
❑ The circular convolution must have a length of at least L + P − 1
points
❑ The DFTs computed to calculate circular convolution must also be
of at least L + P − 1 length
❑ x[n] and h[n] must be augmented with sequence values of zero
amplitude (zero-padding)
28 / 38
Output of an LTI system for infinite-length input
❑ In many applications, the input signal is of indefinite (or very very
long) duration
❑ e.g., filtering a speech waveform
❑ Theoretically, we may store the entire waveform and then
implement the procedure using a DFT for a large number of points
❑ Impractical to compute such large-point DFTs
❑ Filtered samples can be computed only after all the input samples
have been collected
❑ Large delay in processing
❑ Solution: block convolution
❑ Input signal is segmented into sections of length L
❑ Each section is convolved with the finite-length impulse response
(using DFT)
❑ Filtered sections are fitted together appropriately
29 / 38
Example: Block convolution
❑ Consider impulse response h[n] of length P and the signal x[n]
❑ x[n] = 0 for n < 0 and the length of x[n] is much greater than P
30 / 38
Example: Block convolution
❑ x[n] can be represented as a sum of shifted finite-length segments
of length L
(
P∞ x[n + rL], 0 ≤ n ≤ L − 1
❑ x[n] = r =0 xr [n − rL], where xr [n] =
0, otherwise
31 / 38
Example: Block convolution
❑ Since convolution is a linear time-invariant operation
P∞
❑ y [n] = x[n] ∗ h[n] = r =0 yr [n − rL], where yr [n] = xr [n] ∗ h[n]
❑ xr [n] have only L nonzero points and h[n] is of length P
❑ → Each of the terms yr [n] has length L + P − 1
❑ Beginning of each input section is separated from its neighbors by
L points
❑ Each filtered section has length L + P − 1
❑ → Nonzero points in the filtered sections will overlap by P − 1
points
❑ These overlapping samples must be added to compute y [n]
❑ Overlap-add method
32 / 38
Example: Block convolution
33 / 38
Alternative approach: Overlap-save
❑ Implement an L-point circular convolution of a P-point impulse
response h[n] with an L-point segment xr [n]
❑ Identify the part of the circular convolution that corresponds to a
linear convolution
❑ Resulting output segments are then “patched together” to form the
output
❑ If an L-point sequence is circularly convolved with a P-point
sequence (P < L)
❑ First P − 1 points of the result are incorrect
❑ Remaining points are identical to linear convolution
❑ Divide x[n] into sections of length L so that each input section
overlaps the preceding section by P − 1 points
❑ xr [n] = x[n + r (L − P + 1) − P + 1], 0 ≤ n ≤ L − 1
34 / 38
Alternative approach: Overlap-save
35 / 38
Alternative approach: Overlap-save
❑ Circular convolution of xr [n] with h[n] is denoted by yrp [n]
36 / 38
Alternative approach: Overlap-save
❑ Portion of each output section in the region 0 ≤ n ≤ P − 2 must be
discarded (due to aliasing)
❑ Remaining samples from successive sections are then
concatenated to construct the final filtered output
P∞
❑ y [n] = (r =0 yr [n − r (L − P + 1) + P − 1]
yrp [n], P − 1 ≤ n ≤ L − 1
❑ yr [n] =
0, otherwise
❑ Overlap-save method
37 / 38
Thanks.