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.

2.7 Sparse Linear Systems 77<br />

Finally, solve the one further auxiliary problem<br />

A · y = b (2.7.20)<br />

In terms of these quantities, the solution is given by<br />

�<br />

x = y − Z · H · (V T �<br />

· y)<br />

(2.7.21)<br />

Inversion by Partitioning<br />

Once in a while, you will encounter a matrix (not even necessarily sparse)<br />

that can be inverted efficiently by partitioning.<br />

A is partitioned into<br />

Suppose that the N × N matrix<br />

�<br />

P<br />

A =<br />

R<br />

�<br />

Q<br />

S<br />

(2.7.22)<br />

where P and S are square matrices of size p × p and s × s respectively (p + s = N).<br />

The matrices Q and R are not necessarily square, and have sizes p × s and s × p,<br />

respectively.<br />

If the inverse of A is partitioned in the same manner,<br />

A −1 �<br />

�P Q�<br />

=<br />

�R � �<br />

(2.7.23)<br />

S<br />

then � P, � Q, � R, � S, which have the same sizes as P, Q, R, S, respectively, can be<br />

found by either the formulas<br />

�P =(P − Q · S −1 · R) −1<br />

�Q = −(P − Q · S −1 · R) −1 · (Q · S −1 )<br />

�R = −(S −1 · R) · (P − Q · S −1 · R) −1<br />

�S = S −1 +(S −1 · R) · (P − Q · S −1 · R) −1 · (Q · S −1 )<br />

or else by the equivalent formulas<br />

�P = P −1 +(P −1 · Q) · (S − R · P −1 · Q) −1 · (R · P −1 )<br />

�Q = −(P −1 · Q) · (S − R · P −1 · Q) −1<br />

�R = −(S − R · P −1 · Q) −1 · (R · P −1 )<br />

�S =(S − R · P −1 · Q) −1<br />

(2.7.24)<br />

(2.7.25)<br />

The parentheses in equations (2.7.24) and (2.7.25) highlight repeated factors that<br />

you may wish to compute only once. (Of course, by associativity, you can instead<br />

do the matrix multiplications in any order you like.) The choice between using<br />

equation (2.7.24) and (2.7.25) depends on whether you want � P or � S to have the<br />

simpler formula; or on whether the repeated expression (S − R · P −1 · Q) −1 is easier<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!