17.11.2012 Views

Numerical recipes

Numerical recipes

Numerical recipes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

in terms of which<br />

2.11 Is Matrix Inversion an N 3 Process? 103<br />

c11 = Q1 + Q4 − Q5 + Q7<br />

c21 = Q2 + Q4<br />

c12 = Q3 + Q5<br />

c22 = Q1 + Q3 − Q2 + Q6<br />

(2.11.4)<br />

What’s the use of this? There is one fewer multiplication than in equation<br />

(2.11.2), but many more additions and subtractions. It is not clear that anything<br />

has been gained. But notice that in (2.11.3) the a’s and b’s are never commuted.<br />

Therefore (2.11.3) and (2.11.4) are valid when the a’s and b’s are themselves matrices.<br />

The problem of multiplying two very large matrices (of order N =2m for some<br />

integer m) can now be broken down recursively by partitioning the matrices into<br />

quarters, sixteenths, etc. And note the key point: The savings is not just a factor<br />

“7/8”; it is that factor at each hierarchical level of the recursion. In total it reduces<br />

the process of matrix multiplication to order N log2 7 instead of N 3 .<br />

What about all the extra additions in (2.11.3)–(2.11.4)? Don’t they outweigh<br />

the advantage of the fewer multiplications? For large N, it turns out that there are<br />

six times as many additions as multiplications implied by (2.11.3)–(2.11.4). But,<br />

if N is very large, this constant factor is no match for the change in the exponent<br />

from N 3 to N log2 7 .<br />

With this “fast” matrix multiplication, Strassen also obtained a surprising result<br />

for matrix inversion [1]. Suppose that the matrices<br />

� � � �<br />

a11 a12<br />

c11 c12<br />

a21 a22<br />

and<br />

c21 c22<br />

(2.11.5)<br />

are inverses of each other. Then the c’s can be obtained from the a’s by the following<br />

operations (compare equations 2.7.22 and 2.7.25):<br />

R1 = Inverse(a11)<br />

R2 = a21 × R1<br />

R3 = R1 × a12<br />

R4 = a21 × R3<br />

R5 = R4 − a22<br />

R6 = Inverse(R5)<br />

c12 = R3 × R6<br />

c21 = R6 × R2<br />

R7 = R3 × c21<br />

c11 = R1 − R7<br />

c22 = −R6<br />

(2.11.6)<br />

Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)<br />

Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by <strong>Numerical</strong> Recipes Software.<br />

Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable<br />

files (including this one) to any server computer, is strictly prohibited. To order <strong>Numerical</strong> Recipes books or CDROMs, visit website<br />

http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!