Sie sind auf Seite 1von 1

ESO207: Data Structures and Algorithms

Programming Assignment 1 Due: August 26 midnight

Instructions: The precise input-output format will be specified by Programming TAs for SPOJ.
Problem 1. FFT

1. Write the following program. Input: Given a polynomial A(x) that is specified by providing
its degree n − 1, and its n coefficients a0 , a1 , . . . , an−1 in order. Let a be the n-dimensional
vector of its coefficients. Output DFT (a, n). Recall that DFT (a, n) is defined as
A(wn0 )
 
 A(w1 ) 
n 
DFT(a, n) =   .

..
 . 
A(wnn−1 )

2. Write the following program. Given an n-dimensional vector of complex numbers y =


[y0 , y1 , . . . , yn−1 ] output DFT−1
n (y). See note 2 below.

Notes.

1. Note that the input coefficients for A(x) can be complex numbers.
2. Let Fn denote the n × n DFT matrix. That is,
 
1 1 1 ... 1
1 ωn
 ωn2 . . . ωnn−1  
2(n−1) 
1 ωn2 ωn4 . . . ωn

Fn =  
 .
.. .. .. 
. .
 
 
2(n−1) (n−1)2
1 ωnn−1 ωn . . . ωn
Recall by taking inner-product of any two columns that Fn∗ Fn = nI. Hence, Fn−1 = n1 Fn∗ and
therefore,
(DFT)−1 ∗
n (y) = (1/n)Fn (y) .
We obtain two ways of computing DFT−1 ∗ ∗
n . From definition of Fn , we have that Fn is the
same as that of Fn∗ with ωn replaced by ωn = ωn−1 = e−2πi/n . So, in the computation of Fn y,
if we replace the role of ωn by ωn−1 appropriately throughout, and divide by n, we should
obtain DFT−1 (y). The second method comes by observing the rows of Fn∗ and relating them
to rows of Fn .
 
1 1 1 ... 1
1
 ωn ωn 2 . . . ωn n−1  
2 4 . . . ωn 2(n−1) 
Fn∗ = 1 ωn ωn


 .. .. .. 
 . . . 
2
1 ωn n−1 ωn 2(n−1) . . . ωn (n−1)

Das könnte Ihnen auch gefallen