1 / 18

A Straightforward way of O( n 2 ) time !!! n 2 multiplications

w : the primitive n th root of unity. A Straightforward way of O( n 2 ) time !!! n 2 multiplications. …………………………………. …………………………………. P ( x ) = P n -1 x n -1 + P n -2 x n -2 + … + P 1 x 1 + P 0 n = 2 k. k 4. P ( x ) = P 0 + P 1 x + … + P 15 x 15. n = 2 4. 3.

myron
Télécharger la présentation

A Straightforward way of O( n 2 ) time !!! n 2 multiplications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. w : theprimitive nth root of unity A Straightforward way of O(n2) time !!! n2 multiplications …………………………………. ………………………………….

  2. P(x) = Pn-1xn-1 + Pn-2xn-2 + … + P1x1 +P0 n = 2k

  3. k 4 P(x) = P0 + P1x + … + P15x15 n = 24 3 P1 + P3x + … + P15x7 P0 + P2x + … + P14x7 2 P0 + P4x + P8x2 + P12x3 P1 + P5x + P9x2 + P13x3 P2 + P6x + P10x2 + P14x3 P3 + P7x + P11x2 + P15x3 1 P0 + P8x P4 + P12x P2 + P10x P6 + P14x P1 + P9x P5 + P13x P3 + P11x P7 + P15x 0 P0 P8 P4 P12 P2 P10 P6 P14 P1 P9 P5 P13 P3 P11 P7 P15 For a polynomial p at any internal node, the left child is peven and the right child is podd

  4. n = 2k p(xi) p(-xi) Level l Level l+1 Peven((wi)2) Podd((wi)2) xi = wi i i i i

  5. procedureRecursiveFFT(P:RealArray; k,m:integer; vartransform:ComplexArray); var evens, odds : ComplexArray; xPOdd : Complex; j : integer; begin ifk=0 then transform[0] = p0; else {Evaluate peven at the 2k-1th roots of 1} RecursiveFFT((p0,p2,, ); k–1; 2m; evens); : M(k–1) {Evaluate poddat the 2k-1th roots of 1} RecursiveFFT((p1,p3,, ); k–1; 2m; odds); : M(k–1) for j := 0 to 2k-1–1 do {evaluate p(wj) and } xPOdd := omega[mj] ×odds[j]; transform[j] := evens[j] + xPOdd; 2k–1 {Compute } transform[2k-1 + j] := evens[j] – xPOdd end{for} end{if} end{RecursiveFFT} M(k) = 2M(k–1) + 2k–1

  6. n = 2k,n/2 = 2k–1, k = log n M(0) = 0 M(k) = 2k–1 + 2M(k–1) = 2k–1 + 2·2k–2 + 22M(k–2) M(k) = k·2k–1 = (n/2)log2n O(nlog n) 2(2k–2 + 2M(k–2)) = 2k–1 + 4M(k–2)

  7. Convolution

  8. Convolution

  9. Pm 0’s Qm 0’s

  10. Given p(x) and q(x), find r(x). (symbolic Multiplication) (1) Evaluate p(x) and q(x) at 2m points. x0, x1, x2, ···, x2m-1 (2) r(xi)=p(xi) q(xi) , i = 0, 1, ···,2m-1 (xi,r(xi)), i = 0, 1, ···, 2m-1 (3) Compute (r0, r1, ···, r2m-1) r(x) = p(x) · q(x) r(x) = r2m-1x2m-1 + ··· + r0

  11. Step (1) xi= wi i = 0,1,···, 2m-1 p(wi) q(wi) O(mlog m) Why? Step (2) r(xi) = p(xi) q(xi) i = 0,1,···, 2m-1 O(m) Step (3) wi r(wi) (xi,r(xi)) r(wi) = r0 + r1(wi)1 + r2(wi)2 + ··· + r2m-1(wi)2m-1 r(wi) = zi F2mR = Z R = F2m–1Z i = 0,1,···, 2m-1 r(wi) = p(wi) q(wi)

  12. Pairwise Multiplication

  13. Lemma : Forn>0, Fnis invertible and the (i, j)th entry of its inverse is (1/n)w-ij for 0 i, j n-1 [ Proof ] c = Why? n does not divide i–j if i  j

  14. Theorem 7.7 Let U and V be n-vectors. Then UV = Fn-1(FnU*FnV), where * denotes multiplication. Fn(UV) = FnU*FnV [ Proof ] We show that Fn(UV) = FnU*FnV. For 0 i n–1, the i th component of FnU*FnV is The t th component of UV is where subscripts are taken modulo n. Thus the i th component of Fn(UV) is Let k = t – j (mod n) in the inner summation. For each j, since t ranges from 0 to n–1, k will also range from 0 to n–1, although in a different order. Also, for any p, wp = wp(mod n), so the i th component of Fn(UV) is which is exactly the i th component of FnU*FnV

  15. nFn-1 = [w-ij] why ? w-i = wn–iw-i = wn·w-i wn = 1  Row Permutation !!! w(n–i)jw–ij FnnFn–1 n–ith row ith row w(–i)j = w(n-i)j

  16. Algorithm : Inverse Discrete Fourier Transform Input : A, n, where A is an n-vector ; n is a power of 2. Output : The vector B = (b0,b1,···,bn-1), where B = Fn–1A Procedure InverseFT ( A: ComplexArray; n : integer; varB : ComplexArray); var i : integer; transform : ComplexArray ; begin FFT(A, n, transform) ; b0 := transform[0] / n ; for i := 1 ton–1 do bi = transform[n-i] / n ; w-i = wn-i end { for } ;  row permutation end { inverseFT } ;

More Related