Вы находитесь на странице: 1из 9

Complexity of Filtering and the FFT

Complexity of Filtering in the Time-Domain

Digital Filtering in the Time Domain


Let x(n) and h(n) be real signals.
Let the support of x(n) be n = 0, 1, . . . , N 1. We are interested in
determining y (n) for n = 0, 1, . . . , N 1.

Complexity of Filtering and the FFT


Dr. Deepa Kundur

y (n) = x(n) h(n)

X
=
x(k)h(n k)

University of Toronto

k=

N1
X

x(k)h(n k)

n = 0, 1, . . . , N 1

k=0

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

Complexity of Filtering and the FFT

1 / 34

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering in the Time-Domain

Complexity of Filtering and the FFT

Digital Filtering in the Time Domain

k=0

Complexity of Filtering in the Time-Domain

Is O(N 2 ) high?
I

N real multiplications
N 1 real additions

For all n (n=0, 1, . . . , N-1):


I

2 / 34

Complexity of Digital Filtering in the Time Domain

Complexity of doing a brute-force convolution is given by:


I For fixed n:
N1
X
y (n) =
x(k)h(n k)

Complexity of Filtering and the FFT

Yes.

Idea: Maybe filtering in the frequency domain can reduce


complexity.

NN = N 2 = O(N 2 ) real multiplications


(N 1)N = N(N 1) = O(N 2 ) real additions

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

3 / 34

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

4 / 34

Complexity of Filtering and the FFT

DFT

Complexity of Filtering and the FFT

Discrete Fourier Transform (DFT)

Fourier Duality

Frequency analysis of discrete-time signals is conveniently


performed on a DSP.
Therefore, both time-domain and frequency-domain signals must
be discrete.

Time Domain
sinc
rectangle

Frequency Domain
rectangle
sinc

sinc2
triangle

triangle
sinc2

ringing
truncation

truncation
ringing

discrete
periodic

periodic
discrete

continuous
aperiodic

aperiodic
continuous

sampling

x(t) x(n)

X () X ( 2k
N ) or X (k)

DFT

sampling

What happens when we sample in the frequency domain?

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

Complexity of Filtering and the FFT

5 / 34

Dr. Deepa Kundur (University of Toronto)

DFT

Complexity of Filtering and the FFT

Complexity of Filtering and the FFT

DFT Intuition

among others . . .

6 / 34

DFT

DFT Intuition
Example

aperiodic + dst in time cts + periodic in freq


sampling

periodic + dst in freq-domain

periodic + dst in time-domain

periodic + dst in time dst + periodic in freq

DTFS
1

DTFS

periodic + discrete periodic + discrete

-7

-6

-5

-4

-3

-2

-1

-7

-6

DFT

x(n)

-5

-4

-3

-2

-1

X(k)

DFT

one period of dst samples one period of dst samples


n = 0, 1, . . . , N 1
k = 0, 1, . . . , N 1

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

note: signal examples are artificial

7 / 34

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

8 / 34

Complexity of Filtering and the FFT

DFT

Complexity of Filtering and the FFT

Frequency Domain Sampling


I

Frequency Domain Sampling

Recall, sampling in time results in a periodic repetition in


frequency.
x(n) = xa (t)|t=nT

1 X
2
X () =
Xa ( +
k)
T k=
T

Similarly, sampling in frequency results in periodic repetition in


time.
xp (n) =

x(n + lN)

Dr. Deepa Kundur (University of Toronto)

... -1

X (k) = X ()|= 2 k
N

l=

...

Complexity of Filtering and the FFT

9 / 34

Dr. Deepa Kundur (University of Toronto)

DFT

...

Complexity of Filtering and the FFT

Complexity of Filtering and the FFT

Frequency Domain Sampling and Reconstruction

10 / 34

DFT

Frequency Domain Sampling and Reconstruction

Therefore,
I

x(n) X ()

Q: Can we reconstruct x(n) from the samples of X ()?


I

xp (n) X (k)

Can we reconstruct x(n) from xp (n)?

A: Maybe.
"
xp (n) =

N-1

Note: N is directly proportional to the sampling rate of ; there are N samples


per 2

Complexity of Filtering and the FFT

DFT

#
x(n + lN)

l=

Implications:
I

The samples of X () can be used to reconstruct xp (n).

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

11 / 34

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

12 / 34

Complexity of Filtering and the FFT

DFT

Complexity of Filtering and the FFT

Frequency Domain Sampling and Reconstruction

DFT

Frequency Domain Sampling and Reconstruction

N =4
x(n)

xp(n)

no temporal aliasing

-7

-6

-5

-4

-3

-2

-1

-7

-6

-5

-4

-3

-2

-1

x(n) can be recovered from xp (n) if there is no overlap when


taking the periodic repetition.
If x(n) is finite duration and non-zero in the interval
0 n L 1, then

x(n) = xp (n),

=x(n)
x(n)

time-domain aliasing

-6

-5

-4

-3

-2

-1

-7

-6

-5

-4

-3

-2

-1

when N L

xp(n)
I

If N < L then, x(n) cannot be recovered from xp (n).


I

-7

0n N 1

or equivalently
X () cannot be recovered from its samples

k
due
to
time-domain aliasing
X 2
N

=x(n)
Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

Complexity of Filtering and the FFT

13 / 34

DFT

xp (n) for all n


x(n)
where


x(n) =

and
(k) =
X

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

Complexity of Filtering and the FFT

DTFT, DTFS and DFT

x(n) for all n

Dr. Deepa Kundur (University of Toronto)

14 / 34

DFT

The Discrete Fourier Transform Pair

DTFT

DTFS

DFT

X () for all

DFT and inverse-DFT (IDFT):

X (k) for all k

X (k) =

(k)
X

xp (n)
0

for n = 0, . . . , N 1
otherwise

X (k)
0

for n = 0, . . . , N 1
otherwise

Complexity of Filtering and the FFT

x(n) =

N1
X

n=0
N1
X

1
N

x(n)e j2k N ,

k = 0, 1, . . . , N 1
n

X (k)e j2k N ,

n = 0, 1, . . . , N 1

k=0

Note: we drop the notation from now on.

15 / 34

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

16 / 34

Complexity of Filtering and the FFT

DFT

Complexity of Filtering and the FFT

Important DFT Properties

Property
Notation:
Periodicity:
Linearity:
Time reversal
Circular time shift:
Circular frequency shift:
Complex conjugate:
Circular convolution:
Multiplication:
Parsevals theorem:

Complexity of the DFT (and IDFT)

Time Domain
x(n)
x(n) = x(n + N)
a1 x1 (n) + a2 x2 (n)
x(N n)
x((n l))N
x(n)e j2ln/N
x (n)
x1 (n) x2 (n)
x1 (n)x2 (n)
P
N1

n=0 x(n)y (n)

X (k) =

Frequency Domain
X (k)
X (k) = X (k + N)
a1 X1 (k) + a2 X2 (k)
X (N k)
X (k)e j2kl/N
X ((k l))N
X (N k)
X1 (k)X2 (k)
1
X1 (k) X2 (k)
N P
N1
1

k=0 X (k)Y (k)


N

x(n) =

Complexity of Filtering and the FFT

Complexity of Filtering and the FFT

X (k) =

17 / 34

X (k) =

n=0
N1
X

1
N

n = 0, 1, . . . , N 1

1
N

k = 0, 1, . . . , N 1

X (k)WNkn ,

n = 0, 1, . . . , N 1

k=0
Complexity of Filtering and the FFT

18 / 34

DFT

Complexity of the DFT

k = 0, 1, . . . , N 1

X (k) =

Complexity of Filtering and the FFT

N1
X

x(n)WNkn ,

k = 0, 1, . . . , N 1

n=0

Straightforward implementation of DFT to compute X (k) for


k = 0, 1, . . . , N 1 requires:
I N(N 1) complex additions

1 complex mult =
(aR + jaI )(bR + jbI ) = (aR bR aI bI ) + j(aR bI + aI bR )
= 4 real mult + 2 real add
4N 2 = O(N 2 ) real multiplications

Dr. Deepa Kundur (University of Toronto)

x(n)WNkn ,

Complexity of Filtering and the FFT

Straightforward implementation of DFT to compute X (k) for


k = 0, 1, . . . , N 1 requires:
I N 2 complex multiplications

X (k)e j2k N ,

n=0
N1
X

n=0

k = 0, 1, . . . , N 1

k=0

N1
X

Dr. Deepa Kundur (University of Toronto)

DFT

x(n)WNkn ,

x(n)e j2k N ,

Complexity of the DFT


N1
X

N1
X

New notation: WN = e j N

x(n) =
Dr. Deepa Kundur (University of Toronto)

DFT

19 / 34

1 complex add =
(aR + jaI )+(bR + jbI ) = (aR + bR ) + j(aI + bI ) = 2 real add
2N(N 1) + 2N 2 (from complex mult) real additions
= 2N(2N 1) = O(N 2 ) real additions.

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

20 / 34

Complexity of Filtering and the FFT

DFT

Complexity of Filtering and the FFT

Complexity of the DFT

Complexity of the DFT


I

How can we reduce complexity?


I

Is O(N 2 ) high?

Exploit symmetry of the complex exponential.


k+ N2

WN
I

FFT

k+ N2

Yes. A linear increase in the length of the DFT increases the


complexity by a power of two.
Given the multitude of applications where Fourier analysis is
employed (linear filtering, correlation analysis, spectrum
analysis), a method of efficient computation is needed.

LHS = WN

= WNk
= e j2

k+N/2
N

= e j2 N e j2

N/2
N

= e j2 N e j
k

= e j2 N (cos() + j sin())
k

= e j2 N (1)
k

= e j2 N = WNk = RHS

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

Complexity of Filtering and the FFT

21 / 34

FFT

Complexity of Filtering and the FFT

Complexity of Filtering and the FFT

Complexity of the DFT


I

Dr. Deepa Kundur (University of Toronto)

22 / 34

FFT

Radix-2 FFT: Decimation-in-time

How can we reduce complexity?


I

Exploit periodicity of the complex exponential.

LHS =

WNk+N
WNk+N

X (k) =

j2 k+N
N

=e

j2 Nk j2 N
N

j2 Nk

(cos(2) + j sin(2))

x(n)WNkn

n odd

(N/2)1
k(2m)
x(2m)WN

m=0

X
m=0

23 / 34

Dr. Deepa Kundur (University of Toronto)

k(2m+1)

x(2m + 1)WN

m=0
(N/2)1

(N/2)1

= e j2 N = WNk = RHS

Complexity of Filtering and the FFT

(N/2)1

= e j2 N (1)

Dr. Deepa Kundur (University of Toronto)

k = 0, 1, . . . , N 1

x(n)WNkn +

n even

= e j2 N e j2
= e

x(n)WNkn

n=0

WNk

= e

N1
X

x(2m) WN2km +
| {z }
f1 (m)

X
m=0

x(2m + 1) WN2km WNk


| {z }

Complexity of Filtering and the FFT

f2 (m)

24 / 34

Complexity of Filtering and the FFT

FFT

Complexity of Filtering and the FFT

Radix-2 FFT: Decimation-in-time


Note:

WN2

=e

j 2
2
N

=e

2
j N/2

X (k) =

X
m=0

= WN/2

x(2m) WN2km +
| {z }
f1 (m)

| m=0

X
m=0

N
)
2
N
F2 (k) = F2 (k + )
2

x(2m + 1) WN2km WNk


| {z }
f2 (m)

(N/2)1
km
f1 (m)WN/2

{z

N
DFT
2

of f1 (m)

+WNk

= F1 (k) + WNk F2 (k),

X
| m=0

N
-DFTs:
2

F1 (k) = F1 (k +

(N/2)1

(N/2)1

Radix-2 FFT: Decimation-in-time


Note: since F1 (k) and F2 (k) are

(N/2)1

FFT

we have,

km
f2 (m)WN/2

{z

N
DFT
2

of f2 (m)

X (k) = F1 (k) + WNk F2 (k)


N
N
N
k+ N
X (k + ) = F1 (k + ) + WN 2 F2 (k + )
2
2
2
= F1 (k) WNk F2 (k)

k = 0, 1, . . . , N 1

since WNk+ 2 = e j N (k+ 2 ) = e j N k e j N


Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

Complexity of Filtering and the FFT

25 / 34

Dr. Deepa Kundur (University of Toronto)

FFT

= e j

2
N k

(1) = WNk

Complexity of Filtering and the FFT

Complexity of Filtering and the FFT

Radix-2 FFT: Decimation-in-time

2 N
2

26 / 34

FFT

Radix-2 FFT: Decimation-in-time


Repeating the decimation-in-time for f1 (n) and f2 (n), we obtain:

Therefore,
N
1
2
N
N
X (k + ) = F1 (k) WNk F2 (k) k = 0, 1, . . . , 1
2
2
X (k) = F1 (k) + WNk F2 (k) k = 0, 1, . . . ,

v11 (n)

= f1 (2n) n = 0, 1, . . . , N/4 1

v12 (n)

= f1 (2n + 1)

v21 (n)

= f2 (2n) n = 0, 1, . . . , N/4 1

v22 (n)

= f2 (2n + 1)

n = 0, 1, . . . , N/4 1
n = 0, 1, . . . , N/4 1

and
k
F1 (k) = V11 (k) + WN/2
V12 (k) k = 0, 1, . . . , N/4 1

F1 (k + N/4)
F2 (k)
F2 (k + N/4)

k
V11 (k) WN/2
V12 (k) k = 0, 1, . . . , N/4 1

k
= V21 (k) + WN/2
V22 (k) k = 0, 1, . . . , N/4 1

k
V21 (k) WN/2
V22 (k) k = 0, 1, . . . , N/4 1

consisting of N/4-DFTs.
Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

27 / 34

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

28 / 34

Complexity of Filtering and the FFT

FFT

Complexity of Filtering and the FFT

FFT

Radix-2 FFT: Decimation-in-time

Radix-2 FFT: Decimation-in-time

For N = 8.

For N = 8.

x(0)
x(4)
x(2)
x(6)

Combine
2-point
DFTs

2-point
DFT

x(1)
x(5)

Combine
4-point
DFTs

2-point
DFT

x(3)
x(7)

Combine
2-point
DFTs

2-point
DFT

Dr. Deepa Kundur (University of Toronto)

Stage 1

x(0)

2-point
DFT

x(4)

X(0)
X(1)
X(2)
X(3)
X(4)
X(5)
X(6)
X(7)

Complexity of Filtering and the FFT

Stage 3

X(0)
X(1)

-1
0
W8

x(2)

X(2)

-1
2

x(6)

W8
0

W8

-1

x(5)

0
W8

-1
1
W8
0

W8

-1

-1
0

FFT

2
W8
0

-1

Dr. Deepa Kundur (University of Toronto)

-1
3
W8

-1

X(5)

-1

X(6)
X(7)

Complexity of Filtering and the FFT

Complexity of Filtering and the FFT

FFT Complexity

W8
-1

W8

X(4)

W8

x(3)

29 / 34

X(3)

-1

x(1)

x(7)

Complexity of Filtering and the FFT

W8

Stage 2

30 / 34

FFT

Convolution using FFT

A=a

To compute the convolution of x(n) (support: n = 0, 1, . . . , L 1)


and h(n) (support: n = 0, 1, . . . , M 1):

+ W Nr b

1. Assign N to be the smallest power of 2 such that N = 2r M + L 1.

r
WN

-1

A = a - W Nr b

2. Zero pad both x(n) and h(n) to have support n = 0, 1, . . . , N 1.


3. Take the N-FFT of x(n) to give X (k), k = 0, 1, . . . , N 1.

Each butterfly requires:


I
I

5. Produce Y (k) = X (k) H(k), k = 0, 1, . . . , N 1.

In total, there are:


I
I

4. Take the N-FFT of h(n) to give H(k), k = 0, 1, . . . , N 1.

one complex multiplication


two complex additions
N
2

butterflies per stage


log N stages

6. Take the N-IFFT of Y (k) to give y (n), n = 0, 1, . . . , N 1.

Order of the overall DFT computation is: O(N log N)

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

31 / 34

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

32 / 34

Complexity of Filtering and the FFT

FFT

Complexity of Filtering and the FFT

Convolution using FFT

FFT

Complexity of Convolution using FFT

To compute the convolution of x(n) (support: n = 0, 1, . . . , L 1)


and h(n) (support: n = 0, 1, . . . , M 1):
1. Assign N to be the smallest power of 2 such that N = 2r M + L 1.
2. Zero pad both x(n) and h(n) to have support n = 0, 1, . . . , N 1.
O(1)

Therefore, the overall complexity of conducting convolution via the


FFT is:

3. Take the N-FFT of x(n) to give X (k), k = 0, 1, . . . , N 1.

O(N log N)

4. Take the N-FFT of h(n) to give H(k), k = 0, 1, . . . , N 1.


O(N log N)

which is lower than O(N 2 ) through direction computation of


convolution in the time-domain.

5. Produce Y (k) = X (k) H(k), k = 0, 1, . . . , N 1.


O(N)

6. Take the N-IFFT of Y (k) to give y (n), n = 0, 1, . . . , N 1.


O(N log N)

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

33 / 34

Dr. Deepa Kundur (University of Toronto)

Complexity of Filtering and the FFT

34 / 34

Вам также может понравиться