divide and conquer n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Divide-and-Conquer PowerPoint Presentation
Download Presentation
Divide-and-Conquer

Loading in 2 Seconds...

play fullscreen
1 / 9

Divide-and-Conquer - PowerPoint PPT Presentation


  • 135 Views
  • Uploaded on

Divide-and-Conquer. Matrix multiplication and Strassen’s algorithm. [. [. [. a. r. e. f. s. b. [. [. [. =. t. g. c. d. h. u. Matrix Multiplication. How many operations are needed to multiply two 2 by 2 matrices?. [. [. [. a. r. e. f. s. b. [. [. [. =. t. g. c.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Divide-and-Conquer' - laszlo


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
divide and conquer
Divide-and-Conquer
  • Matrix multiplication and Strassen’s algorithm
matrix multiplication

[

[

[

a

r

e

f

s

b

[

[

[

=

t

g

c

d

h

u

Matrix Multiplication
  • How many operations are needed to multiply two 2 by 2 matrices?
traditional approach

[

[

[

a

r

e

f

s

b

[

[

[

=

t

g

c

d

h

u

Traditional Approach
  • r = ae + bg
  • s = af + bh
  • t = ce + dg
  • u = cf + dh
  • 8 multiplications and 4 additions
extending to n by n matrices
Each letter represents an n/2 by n/2 matrix

We can use the breakdown to form a divide and conquer algorithm

[

[

[

A

R

E

F

B

S

[

[

[

=

C

T

G

H

U

D

Extending to n by n matrices
  • R = AE + BG
  • S = AF + BH
  • T = CE + DG
  • U = CF + DH
  • 8 multiplications of n/2 by n/2 matrices
  • T(n) = 8 T(n/2) + Q(n2)
  • T(n) = Q(n3)
example
R = AE + BG

S = AF + BH

T = CE + DG

U = CF + DH

[

[

17 18 19 20

21 22 23 24

25 26 27 28

29 30 31 32

Example

[

[

[

[

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 16

=

  • What are A, B, …, H?
  • What happens at this level of the D&C multiplication?
strassen s approach
p1 = a(f – h)

p2 = (a+b)h

p3 = (c+d)e

p4 = d(g-e)

p5 = (a+d)(e + h)

p6 = (b-d)(g+h)

p7 = (a-c)(e+f)

r = p5 + p4 - p2 + p6

s = p1 + p2

t = p3 + p4

u = p5 + p1 – p3 – p7

7 multiplications

18 additions

[

[

[

r

e

a

f

b

s

[

[

[

=

c

t

g

d

h

u

Strassen’s Approach
extending to n by n matrices1
Each letter represents an n/2 by n/2 matrix

We can use the breakdown to form a divide and conquer algorithm

[

[

[

A

R

E

F

B

S

[

[

[

=

C

T

G

H

U

D

Extending to n by n matrices
  • 7 multiplications of n/2 by n/2 matrices
  • 18 additions of n/2 by n/2 matrices
  • T(n) = 7 T(n/2) + Q(n2)
  • T(n) = Q(nlg 7)
example1
p1 = a(f – h)

p2 = (a+b)h

p3 = (c+d)e

p4 = d(g-e)

p5 = (a+d)(e + h)

p6 = (b-d)(g+h)

p7 = (a-c)(e+f)

r = p5 + p4 - p2 + p6

s = p1 + p2

t = p3 + p4

u = p5 + p1 – p3 – p7

[

[

[

Example

[

[

[

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 16

17 18 19 20

21 22 23 24

25 26 27 28

29 30 31 32

=

  • What are A, B, …, H?
  • What happens at this level of the D&C multiplication?
observations
Observations
  • Comparison: n= 70
    • Direct multiplication: 703 = 343,000
    • Strassen: 70lg 7 is approximately 150,000
    • Crossover point typically around n = 20
  • Hopcroft and Kerr have shown 7 multiplications are necessary to multiply 2 by 2 matrices
    • But we can do better with larger matrices
  • Current best is O(n2.376) by Coppersmith and Winograd, but it is not practical
  • Best lower bound is W(n2) (since there are n2 entries)
  • Matrix multiplication can be used in some graph algorithms as a fundamental step, so theoretical improvements in the efficiency of this operation can lead to theoretical improvements in those algorithms