<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lindons Log</title>
	<atom:link href="http://www.lindonslog.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lindonslog.com</link>
	<description></description>
	<lastBuildDate>Fri, 17 May 2013 17:50:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Multivariate Normal Conditional Distribution</title>
		<link>http://www.lindonslog.com/mathematics/multivariate-normal-conditional-distribution/</link>
		<comments>http://www.lindonslog.com/mathematics/multivariate-normal-conditional-distribution/#comments</comments>
		<pubDate>Wed, 15 May 2013 23:19:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mathematics]]></category>

		<guid isPermaLink="false">http://www.lindonslog.com/?p=218</guid>
		<description><![CDATA[<p>Previously I made a post about diagonalizing a positive definite symmetric matrix . One of the applications of this within statistics is to diagonalize the variance matrix of a multivariate normal in order to derive conditional distributions. Let Consider multiplying Y by the following matrix i.e. The covariance matrix has now been diagonalized. This is [...]</p><p>The post <a href="http://www.lindonslog.com/mathematics/multivariate-normal-conditional-distribution/">Multivariate Normal Conditional Distribution</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Previously I made a post about<a href="http://www.lindonslog.com/mathematics/diagonalize-positive-definite-symmetric-matrix-schur-complement-ldu-decomposition/" title="Diagonalize a Positive-Definite Symmetric Matrix using the Schur Complement and LDU Decomposition"> diagonalizing a positive definite symmetric matrix </a>. One of the applications of this within statistics is to diagonalize the variance matrix of a multivariate normal in order to derive conditional distributions. Let</p>
<p><img src="//s0.wp.com/latex.php?latex=Y%5Csim+N_%7Bp%7D%28m%2CV%29++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="Y&#92;sim N_{p}(m,V)  " title="Y&#92;sim N_{p}(m,V)  " class="latex" /><br />
Consider multiplying Y by the following matrix<br />
<img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++1+%26+-V_%7B12%7DV_%7B22%7D%5E%7B-1%7D%5C%5C++++++++++0+%26+1%5C%5C++%5Cend%7Bpmatrix%7DY+%5Csim+N_%7Bp%7D%5Cleft%28+%5Cbegin%7Bpmatrix%7D+m_%7B1%7D+-+V_%7B12%7DV_%7B22%7D%5E%7B-1%7Dm_%7B2%7D+%5C%5C+m_%7B2%7D%5C%5C+%5Cend%7Bpmatrix%7D%2C%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D-V_%7B12%7DV_%7B22%7D%5E%7B-1%7DV_%7B21%7D+%26+0+%5C%5C++++++++++0+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D%5Cright%29++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          1 &amp; -V_{12}V_{22}^{-1}&#92;&#92;          0 &amp; 1&#92;&#92;  &#92;end{pmatrix}Y &#92;sim N_{p}&#92;left( &#92;begin{pmatrix} m_{1} - V_{12}V_{22}^{-1}m_{2} &#92;&#92; m_{2}&#92;&#92; &#92;end{pmatrix},&#92;begin{pmatrix}          V_{11}-V_{12}V_{22}^{-1}V_{21} &amp; 0 &#92;&#92;          0 &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}&#92;right)  " title="&#92;begin{pmatrix}          1 &amp; -V_{12}V_{22}^{-1}&#92;&#92;          0 &amp; 1&#92;&#92;  &#92;end{pmatrix}Y &#92;sim N_{p}&#92;left( &#92;begin{pmatrix} m_{1} - V_{12}V_{22}^{-1}m_{2} &#92;&#92; m_{2}&#92;&#92; &#92;end{pmatrix},&#92;begin{pmatrix}          V_{11}-V_{12}V_{22}^{-1}V_{21} &amp; 0 &#92;&#92;          0 &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}&#92;right)  " class="latex" /><br />
i.e.<br />
<img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++Y_%7B1%7D-V_%7B12%7DV_%7B22%7D%5E%7B-1%7DY_%7B2%7D+%5C%5C++++++++++Y_%7B2%7D%5C%5C++%5Cend%7Bpmatrix%7D%5Csim++N%5Cleft%28++%5Cbegin%7Bpmatrix%7D+m_%7B1%7D+-+V_%7B12%7DV_%7B22%7D%5E%7B-1%7Dm_%7B2%7D+%5C%5C+m_%7B2%7D%5C%5C+%5Cend%7Bpmatrix%7D%2C%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D-V_%7B12%7DV_%7B22%7D%5E%7B-1%7DV_%7B21%7D+%26+0+%5C%5C++++++++++0+%26+V_%7B22%7D%5Cend%7Bpmatrix%7D+%5Cright%29%5C%5C++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          Y_{1}-V_{12}V_{22}^{-1}Y_{2} &#92;&#92;          Y_{2}&#92;&#92;  &#92;end{pmatrix}&#92;sim  N&#92;left(  &#92;begin{pmatrix} m_{1} - V_{12}V_{22}^{-1}m_{2} &#92;&#92; m_{2}&#92;&#92; &#92;end{pmatrix},&#92;begin{pmatrix}          V_{11}-V_{12}V_{22}^{-1}V_{21} &amp; 0 &#92;&#92;          0 &amp; V_{22}&#92;end{pmatrix} &#92;right)&#92;&#92;  " title="&#92;begin{pmatrix}          Y_{1}-V_{12}V_{22}^{-1}Y_{2} &#92;&#92;          Y_{2}&#92;&#92;  &#92;end{pmatrix}&#92;sim  N&#92;left(  &#92;begin{pmatrix} m_{1} - V_{12}V_{22}^{-1}m_{2} &#92;&#92; m_{2}&#92;&#92; &#92;end{pmatrix},&#92;begin{pmatrix}          V_{11}-V_{12}V_{22}^{-1}V_{21} &amp; 0 &#92;&#92;          0 &amp; V_{22}&#92;end{pmatrix} &#92;right)&#92;&#92;  " class="latex" /><br />
The covariance matrix has now been diagonalized. This is useful because zero covariance implies independence for normally distributed random variables and so it follows that</p>
<p><img src="//s0.wp.com/latex.php?latex=Y_%7B1%7D-V_%7B12%7DV_%7B22%7D%5E%7B-1%7DY_%7B2%7D+%5Csim+N%28+m_%7B1%7D+-+V_%7B12%7DV_%7B22%7D%5E%7B-1%7Dm_%7B2%7D+%2CV_%7B11%7D-V_%7B12%7DV_%7B22%7D%5E%7B-1%7DV_%7B21%7D%29++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="Y_{1}-V_{12}V_{22}^{-1}Y_{2} &#92;sim N( m_{1} - V_{12}V_{22}^{-1}m_{2} ,V_{11}-V_{12}V_{22}^{-1}V_{21})  " title="Y_{1}-V_{12}V_{22}^{-1}Y_{2} &#92;sim N( m_{1} - V_{12}V_{22}^{-1}m_{2} ,V_{11}-V_{12}V_{22}^{-1}V_{21})  " class="latex" /><br />
Conditiong on Y2 it follows that the conditional distribution is<br />
<img src="//s0.wp.com/latex.php?latex=Y_%7B1%7D%7CY_%7B2%7D+%5Csim+N%28+m_%7B1%7D+%2B+V_%7B12%7DV_%7B22%7D%5E%7B-1%7D%28Y_%7B2%7D-m_%7B2%7D+%29%2CV_%7B11%7D-V_%7B12%7DV_%7B22%7D%5E%7B-1%7DV_%7B21%7D%29++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="Y_{1}|Y_{2} &#92;sim N( m_{1} + V_{12}V_{22}^{-1}(Y_{2}-m_{2} ),V_{11}-V_{12}V_{22}^{-1}V_{21})  " title="Y_{1}|Y_{2} &#92;sim N( m_{1} + V_{12}V_{22}^{-1}(Y_{2}-m_{2} ),V_{11}-V_{12}V_{22}^{-1}V_{21})  " class="latex" /><br />
Notice how the variance of the conditional normal distribution is the marginal variance of Y1 minus something. That is to say the variance of Y1 is reduced given the knowledge of Y2. The variance can be recognized as the Schur complement of the covariance matrix with respect to V22. A similar treatment yields<br />
<img src="//s0.wp.com/latex.php?latex=Y_%7B2%7D%7CY_%7B1%7D+%5Csim+N%28+m_%7B2%7D+%2B+V_%7B21%7DV_%7B11%7D%5E%7B-1%7D%28Y_%7B1%7D-m_%7B1%7D+%29%2CV_%7B22%7D-V_%7B21%7DV_%7B11%7D%5E%7B-1%7DV_%7B12%7D%29++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="Y_{2}|Y_{1} &#92;sim N( m_{2} + V_{21}V_{11}^{-1}(Y_{1}-m_{1} ),V_{22}-V_{21}V_{11}^{-1}V_{12})  " title="Y_{2}|Y_{1} &#92;sim N( m_{2} + V_{21}V_{11}^{-1}(Y_{1}-m_{1} ),V_{22}-V_{21}V_{11}^{-1}V_{12})  " class="latex" /></p>
<p>The post <a href="http://www.lindonslog.com/mathematics/multivariate-normal-conditional-distribution/">Multivariate Normal Conditional Distribution</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.lindonslog.com/mathematics/multivariate-normal-conditional-distribution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Block Matrix Inverse</title>
		<link>http://www.lindonslog.com/mathematics/block-matrix-inverse/</link>
		<comments>http://www.lindonslog.com/mathematics/block-matrix-inverse/#comments</comments>
		<pubDate>Wed, 15 May 2013 22:40:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mathematics]]></category>

		<guid isPermaLink="false">http://www.lindonslog.com/?p=205</guid>
		<description><![CDATA[<p>Previously I wrote a post on the Woodbury matrix inverse formula. One of the results derived was Hence the inverse of a block matrix can be written neatly in one of two ways:</p><p>The post <a href="http://www.lindonslog.com/mathematics/block-matrix-inverse/">Block Matrix Inverse</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Previously I wrote a post on the<a href="http://www.lindonslog.com/mathematics/invert-a-matrix-using-the-woodbury-matrix-inverse-formula-identity/"> Woodbury matrix inverse formula</a>. One of the results derived was<br />
<img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D%5E%7B-1%7D++%3D++%5Cbegin%7Bpmatrix%7D++V_%7B11.2%7D%5E%7B-1%7D+%26+-V_%7B11.2%7D%5E%7B-1%7DV_%7B12%7DV_%7B22%7D%5E%7B-1%7D%5C%5C++-V_%7B22%7D%5E%7B-1%7DV_%7B21%7DV_%7B11.2%7D%5E%7B-1%7D+%26+V_%7B22%7D%5E%7B-1%7D%2BV_%7B22%7D%5E%7B-1%7DV_%7B21%7DV_%7B11.2%7D%5E%7B-1%7DV_%7B12%7DV_%7B22%7D%5E%7B-1%7D++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =  &#92;begin{pmatrix}  V_{11.2}^{-1} &amp; -V_{11.2}^{-1}V_{12}V_{22}^{-1}&#92;&#92;  -V_{22}^{-1}V_{21}V_{11.2}^{-1} &amp; V_{22}^{-1}+V_{22}^{-1}V_{21}V_{11.2}^{-1}V_{12}V_{22}^{-1}  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =  &#92;begin{pmatrix}  V_{11.2}^{-1} &amp; -V_{11.2}^{-1}V_{12}V_{22}^{-1}&#92;&#92;  -V_{22}^{-1}V_{21}V_{11.2}^{-1} &amp; V_{22}^{-1}+V_{22}^{-1}V_{21}V_{11.2}^{-1}V_{12}V_{22}^{-1}  &#92;end{pmatrix}  " class="latex" /></p>
<p><img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D%5E%7B-1%7D++%3D%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D%5E%7B-1%7D%2BV_%7B11%7D%5E%7B-1%7DV_%7B12%7DV_%7B22.1%7D%5E%7B-1%7DV_%7B21%7DV_%7B11%7D%5E%7B-1%7D+%26+-V_%7B11%7D%5E%7B-1%7DV_%7B12%7DV_%7B22.1%7D%5E%7B-1%7D%5C%5C++++++++++-V_%7B22.1%7D%5E%7B-1%7DV_%7B21%7DV_%7B11%7D%5E%7B-1%7D+%26+V_%7B22.1%7D%5E%7B-1%7D++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =&#92;begin{pmatrix}          V_{11}^{-1}+V_{11}^{-1}V_{12}V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; -V_{11}^{-1}V_{12}V_{22.1}^{-1}&#92;&#92;          -V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; V_{22.1}^{-1}  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =&#92;begin{pmatrix}          V_{11}^{-1}+V_{11}^{-1}V_{12}V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; -V_{11}^{-1}V_{12}V_{22.1}^{-1}&#92;&#92;          -V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; V_{22.1}^{-1}  &#92;end{pmatrix}  " class="latex" /></p>
<p>Hence the inverse of a block matrix can be written neatly in one of two ways:<br />
<img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D%5E%7B-1%7D++%3D++%5Cbegin%7Bpmatrix%7D++V_%7B11.2%7D%5E%7B-1%7D+%26+-V_%7B11.2%7D%5E%7B-1%7DV_%7B12%7DV_%7B22%7D%5E%7B-1%7D%5C%5C++-V_%7B22%7D%5E%7B-1%7DV_%7B21%7DV_%7B11.2%7D%5E%7B-1%7D+%26++V_%7B22.1%7D%5E%7B-1%7D++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =  &#92;begin{pmatrix}  V_{11.2}^{-1} &amp; -V_{11.2}^{-1}V_{12}V_{22}^{-1}&#92;&#92;  -V_{22}^{-1}V_{21}V_{11.2}^{-1} &amp;  V_{22.1}^{-1}  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =  &#92;begin{pmatrix}  V_{11.2}^{-1} &amp; -V_{11.2}^{-1}V_{12}V_{22}^{-1}&#92;&#92;  -V_{22}^{-1}V_{21}V_{11.2}^{-1} &amp;  V_{22.1}^{-1}  &#92;end{pmatrix}  " class="latex" /></p>
<p><img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D%5E%7B-1%7D++%3D%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11.2%7D%5E%7B-1%7D+%26+-V_%7B11%7D%5E%7B-1%7DV_%7B12%7DV_%7B22.1%7D%5E%7B-1%7D%5C%5C++++++++++-V_%7B22.1%7D%5E%7B-1%7DV_%7B21%7DV_%7B11%7D%5E%7B-1%7D+%26+V_%7B22.1%7D%5E%7B-1%7D++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =&#92;begin{pmatrix}          V_{11.2}^{-1} &amp; -V_{11}^{-1}V_{12}V_{22.1}^{-1}&#92;&#92;          -V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; V_{22.1}^{-1}  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =&#92;begin{pmatrix}          V_{11.2}^{-1} &amp; -V_{11}^{-1}V_{12}V_{22.1}^{-1}&#92;&#92;          -V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; V_{22.1}^{-1}  &#92;end{pmatrix}  " class="latex" /></p>
<p>The post <a href="http://www.lindonslog.com/mathematics/block-matrix-inverse/">Block Matrix Inverse</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.lindonslog.com/mathematics/block-matrix-inverse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Invert a Matrix using the Woodbury Matrix Inverse Formula Identity</title>
		<link>http://www.lindonslog.com/mathematics/invert-a-matrix-using-the-woodbury-matrix-inverse-formula-identity/</link>
		<comments>http://www.lindonslog.com/mathematics/invert-a-matrix-using-the-woodbury-matrix-inverse-formula-identity/#comments</comments>
		<pubDate>Wed, 15 May 2013 21:39:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mathematics]]></category>

		<guid isPermaLink="false">http://www.lindonslog.com/?p=189</guid>
		<description><![CDATA[<p>Previously I wrote about the LDU decomposition and the Schur complement. These can be further used to derive the Sherman–Morrison–Woodbury formula, otherwise known as the matrix inversion lemma, for inverting a matrix. As shown in the previous post, a UDL and LDU are two ways of factorizing a matrix: Now consider taking the inverse of [...]</p><p>The post <a href="http://www.lindonslog.com/mathematics/invert-a-matrix-using-the-woodbury-matrix-inverse-formula-identity/">Invert a Matrix using the Woodbury Matrix Inverse Formula Identity</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Previously I wrote about the <a href="http://www.lindonslog.com/mathematics/diagonalize-positive-definite-symmetric-matrix-schur-complement-ldu-decomposition/" target="_blank">LDU decomposition and the Schur complement</a>. These can be further used to derive the  Sherman–Morrison–Woodbury formula, otherwise known as the matrix inversion lemma, for inverting a matrix. As shown in the previous post, a UDL and LDU are two ways of factorizing a matrix:</p>
<p><img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D%3D++++%5Cbegin%7Bpmatrix%7D++++++++++1+%26++++V_%7B12%7DV_%7B22%7D%5E%7B-1%7D%5C%5C++0++++++%26+1%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D+++++++++++V_%7B11.2%7D+%26+0+%5C%5C+++++++++++0+%26+V_%7B22%7D+%5C%5C+++%5Cend%7Bpmatrix%7D+++%5Cbegin%7Bpmatrix%7D++++++++++++1+%26+0+%5C%5C++V_%7B22%7D%5E%7B-1%7DV_%7B21%7D+%26+1+%5C%5C++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}=    &#92;begin{pmatrix}          1 &amp;    V_{12}V_{22}^{-1}&#92;&#92;  0      &amp; 1&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}           V_{11.2} &amp; 0 &#92;&#92;           0 &amp; V_{22} &#92;&#92;   &#92;end{pmatrix}   &#92;begin{pmatrix}            1 &amp; 0 &#92;&#92;  V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}=    &#92;begin{pmatrix}          1 &amp;    V_{12}V_{22}^{-1}&#92;&#92;  0      &amp; 1&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}           V_{11.2} &amp; 0 &#92;&#92;           0 &amp; V_{22} &#92;&#92;   &#92;end{pmatrix}   &#92;begin{pmatrix}            1 &amp; 0 &#92;&#92;  V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  " class="latex" /></p>
<p><img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D++++%3D++%5Cbegin%7Bpmatrix%7D++++++++++1+%26+0%5C%5C++++++++++V_%7B21%7DV_%7B11%7D%5E%7B-1%7D+%26+1%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D++++++++++++V_%7B11%7D+%26+0+%5C%5C++0+%26+V_%7B22.1%7D+%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D++++++++++++1+%26+V_%7B11%7D%5E%7B-1%7DV_%7B12%7D+%5C%5C++0+%26+1+%5C%5C++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}    =  &#92;begin{pmatrix}          1 &amp; 0&#92;&#92;          V_{21}V_{11}^{-1} &amp; 1&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            V_{11} &amp; 0 &#92;&#92;  0 &amp; V_{22.1} &#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            1 &amp; V_{11}^{-1}V_{12} &#92;&#92;  0 &amp; 1 &#92;&#92;  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}    =  &#92;begin{pmatrix}          1 &amp; 0&#92;&#92;          V_{21}V_{11}^{-1} &amp; 1&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            V_{11} &amp; 0 &#92;&#92;  0 &amp; V_{22.1} &#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            1 &amp; V_{11}^{-1}V_{12} &#92;&#92;  0 &amp; 1 &#92;&#92;  &#92;end{pmatrix}  " class="latex" /><br />
Now consider taking the inverse of the matrices above, yielding</p>
<p><img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D%5E%7B-1%7D%3D++%5Cbegin%7Bpmatrix%7D++1+%26+0+%5C%5C++-V_%7B22%7D%5E%7B-1%7DV_%7B21%7D+%26+1+%5C%5C++%5Cend%7Bpmatrix%7D++++++%5Cbegin%7Bpmatrix%7D+++++++++++V_%7B11.2%7D%5E%7B-1%7D+%26+0+%5C%5C+++++++++++0+%26+V_%7B22%7D%5E%7B-1%7D+%5C%5C+++%5Cend%7Bpmatrix%7D+++%5Cbegin%7Bpmatrix%7D++++++++++1+%26+++-V_%7B12%7DV_%7B22%7D%5E%7B-1%7D%5C%5C++0++++++%26+1%5C%5C++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}=  &#92;begin{pmatrix}  1 &amp; 0 &#92;&#92;  -V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}      &#92;begin{pmatrix}           V_{11.2}^{-1} &amp; 0 &#92;&#92;           0 &amp; V_{22}^{-1} &#92;&#92;   &#92;end{pmatrix}   &#92;begin{pmatrix}          1 &amp;   -V_{12}V_{22}^{-1}&#92;&#92;  0      &amp; 1&#92;&#92;  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}=  &#92;begin{pmatrix}  1 &amp; 0 &#92;&#92;  -V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}      &#92;begin{pmatrix}           V_{11.2}^{-1} &amp; 0 &#92;&#92;           0 &amp; V_{22}^{-1} &#92;&#92;   &#92;end{pmatrix}   &#92;begin{pmatrix}          1 &amp;   -V_{12}V_{22}^{-1}&#92;&#92;  0      &amp; 1&#92;&#92;  &#92;end{pmatrix}  " class="latex" /></p>
<p><img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D%5E%7B-1%7D++%3D++%5Cbegin%7Bpmatrix%7D++1+%26+-V_%7B11%7D%5E%7B-1%7DV_%7B12%7D+%5C%5C++0+%26+1+%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D++++++V_%7B11%7D%5E%7B-1%7D+%26+0+%5C%5C++0+%26+V_%7B22.1%7D%5E%7B-1%7D+%5C%5C++%5Cend%7Bpmatrix%7D++++%5Cbegin%7Bpmatrix%7D++++++++++1+%26+0%5C%5C++++++++++-V_%7B21%7DV_%7B11%7D%5E%7B-1%7D+%26+1%5C%5C++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =  &#92;begin{pmatrix}  1 &amp; -V_{11}^{-1}V_{12} &#92;&#92;  0 &amp; 1 &#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}      V_{11}^{-1} &amp; 0 &#92;&#92;  0 &amp; V_{22.1}^{-1} &#92;&#92;  &#92;end{pmatrix}    &#92;begin{pmatrix}          1 &amp; 0&#92;&#92;          -V_{21}V_{11}^{-1} &amp; 1&#92;&#92;  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =  &#92;begin{pmatrix}  1 &amp; -V_{11}^{-1}V_{12} &#92;&#92;  0 &amp; 1 &#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}      V_{11}^{-1} &amp; 0 &#92;&#92;  0 &amp; V_{22.1}^{-1} &#92;&#92;  &#92;end{pmatrix}    &#92;begin{pmatrix}          1 &amp; 0&#92;&#92;          -V_{21}V_{11}^{-1} &amp; 1&#92;&#92;  &#92;end{pmatrix}  " class="latex" /><br />
Multiplying the matrices on the RHS yields<br />
<img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D%5E%7B-1%7D++%3D++%5Cbegin%7Bpmatrix%7D++V_%7B11.2%7D%5E%7B-1%7D+%26+-V_%7B11.2%7D%5E%7B-1%7DV_%7B12%7DV_%7B22%7D%5E%7B-1%7D%5C%5C++-V_%7B22%7D%5E%7B-1%7DV_%7B21%7DV_%7B11.2%7D%5E%7B-1%7D+%26+V_%7B22%7D%5E%7B-1%7D%2BV_%7B22%7D%5E%7B-1%7DV_%7B21%7DV_%7B11.2%7D%5E%7B-1%7DV_%7B12%7DV_%7B22%7D%5E%7B-1%7D++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =  &#92;begin{pmatrix}  V_{11.2}^{-1} &amp; -V_{11.2}^{-1}V_{12}V_{22}^{-1}&#92;&#92;  -V_{22}^{-1}V_{21}V_{11.2}^{-1} &amp; V_{22}^{-1}+V_{22}^{-1}V_{21}V_{11.2}^{-1}V_{12}V_{22}^{-1}  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =  &#92;begin{pmatrix}  V_{11.2}^{-1} &amp; -V_{11.2}^{-1}V_{12}V_{22}^{-1}&#92;&#92;  -V_{22}^{-1}V_{21}V_{11.2}^{-1} &amp; V_{22}^{-1}+V_{22}^{-1}V_{21}V_{11.2}^{-1}V_{12}V_{22}^{-1}  &#92;end{pmatrix}  " class="latex" /></p>
<p><img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D%5E%7B-1%7D++%3D%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D%5E%7B-1%7D%2BV_%7B11%7D%5E%7B-1%7DV_%7B12%7DV_%7B22.1%7D%5E%7B-1%7DV_%7B21%7DV_%7B11%7D%5E%7B-1%7D+%26+-V_%7B11%7D%5E%7B-1%7DV_%7B12%7DV_%7B22.1%7D%5E%7B-1%7D%5C%5C++++++++++-V_%7B22.1%7D%5E%7B-1%7DV_%7B21%7DV_%7B11%7D%5E%7B-1%7D+%26+V_%7B22.1%7D%5E%7B-1%7D++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =&#92;begin{pmatrix}          V_{11}^{-1}+V_{11}^{-1}V_{12}V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; -V_{11}^{-1}V_{12}V_{22.1}^{-1}&#92;&#92;          -V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; V_{22.1}^{-1}  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}^{-1}  =&#92;begin{pmatrix}          V_{11}^{-1}+V_{11}^{-1}V_{12}V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; -V_{11}^{-1}V_{12}V_{22.1}^{-1}&#92;&#92;          -V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; V_{22.1}^{-1}  &#92;end{pmatrix}  " class="latex" /><br />
These two results can be used to form neat expressions for the <a href="http://www.lindonslog.com/mathematics/block-matrix-inverse/" title="Block Matrix Inverse">inverse of a partitioned block matrix</a>. It follows that<br />
<img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++V_%7B11.2%7D%5E%7B-1%7D+%26+-V_%7B11.2%7D%5E%7B-1%7DV_%7B12%7DV_%7B22%7D%5E%7B-1%7D%5C%5C++-V_%7B22%7D%5E%7B-1%7DV_%7B21%7DV_%7B11.2%7D%5E%7B-1%7D+%26+V_%7B22%7D%5E%7B-1%7D%2BV_%7B22%7D%5E%7B-1%7DV_%7B21%7DV_%7B11.2%7D%5E%7B-1%7DV_%7B12%7DV_%7B22%7D%5E%7B-1%7D++%5Cend%7Bpmatrix%7D%3D++%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D%5E%7B-1%7D%2BV_%7B11%7D%5E%7B-1%7DV_%7B12%7DV_%7B22.1%7D%5E%7B-1%7DV_%7B21%7DV_%7B11%7D%5E%7B-1%7D+%26+-V_%7B11%7D%5E%7B-1%7DV_%7B12%7DV_%7B22.1%7D%5E%7B-1%7D%5C%5C++++++++++-V_%7B22.1%7D%5E%7B-1%7DV_%7B21%7DV_%7B11%7D%5E%7B-1%7D+%26+V_%7B22.1%7D%5E%7B-1%7D++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}  V_{11.2}^{-1} &amp; -V_{11.2}^{-1}V_{12}V_{22}^{-1}&#92;&#92;  -V_{22}^{-1}V_{21}V_{11.2}^{-1} &amp; V_{22}^{-1}+V_{22}^{-1}V_{21}V_{11.2}^{-1}V_{12}V_{22}^{-1}  &#92;end{pmatrix}=  &#92;begin{pmatrix}          V_{11}^{-1}+V_{11}^{-1}V_{12}V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; -V_{11}^{-1}V_{12}V_{22.1}^{-1}&#92;&#92;          -V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; V_{22.1}^{-1}  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}  V_{11.2}^{-1} &amp; -V_{11.2}^{-1}V_{12}V_{22}^{-1}&#92;&#92;  -V_{22}^{-1}V_{21}V_{11.2}^{-1} &amp; V_{22}^{-1}+V_{22}^{-1}V_{21}V_{11.2}^{-1}V_{12}V_{22}^{-1}  &#92;end{pmatrix}=  &#92;begin{pmatrix}          V_{11}^{-1}+V_{11}^{-1}V_{12}V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; -V_{11}^{-1}V_{12}V_{22.1}^{-1}&#92;&#92;          -V_{22.1}^{-1}V_{21}V_{11}^{-1} &amp; V_{22.1}^{-1}  &#92;end{pmatrix}  " class="latex" /><br />
The equality holds for each block or element, so two expressions can be found for the Woodbury matrix inverse formula, namely:<br />
<img src="//s0.wp.com/latex.php?latex=V_%7B11.2%7D%5E%7B-1%7D%3DV_%7B11%7D%5E%7B-1%7D%2BV_%7B11%7D%5E%7B-1%7DV_%7B12%7DV_%7B22.1%7D%5E%7B-1%7DV_%7B21%7DV_%7B11%7D%5E%7B-1%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="V_{11.2}^{-1}=V_{11}^{-1}+V_{11}^{-1}V_{12}V_{22.1}^{-1}V_{21}V_{11}^{-1}  " title="V_{11.2}^{-1}=V_{11}^{-1}+V_{11}^{-1}V_{12}V_{22.1}^{-1}V_{21}V_{11}^{-1}  " class="latex" /><br />
and<br />
<img src="//s0.wp.com/latex.php?latex=V_%7B22.1%7D%5E%7B-1%7D%3DV_%7B22%7D%5E%7B-1%7D%2BV_%7B22%7D%5E%7B-1%7DV_%7B21%7DV_%7B11.2%7D%5E%7B-1%7DV_%7B12%7DV_%7B22%7D%5E%7B-1%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="V_{22.1}^{-1}=V_{22}^{-1}+V_{22}^{-1}V_{21}V_{11.2}^{-1}V_{12}V_{22}^{-1}  " title="V_{22.1}^{-1}=V_{22}^{-1}+V_{22}^{-1}V_{21}V_{11.2}^{-1}V_{12}V_{22}^{-1}  " class="latex" /><br />
where the dot notation corresponds to the Schur complement i.e.<br />
<img src="//s0.wp.com/latex.php?latex=V_%7B11.2%7D%3DV_%7B11%7D-V_%7B12%7DV_%7B22%7D%5E%7B-1%7DV_%7B21%7D%5C%5C++V_%7B22.1%7D%3DV_%7B22%7D-V_%7B21%7DV_%7B11%7D%5E%7B-1%7DV_%7B12%7D%5C%5C++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="V_{11.2}=V_{11}-V_{12}V_{22}^{-1}V_{21}&#92;&#92;  V_{22.1}=V_{22}-V_{21}V_{11}^{-1}V_{12}&#92;&#92;  " title="V_{11.2}=V_{11}-V_{12}V_{22}^{-1}V_{21}&#92;&#92;  V_{22.1}=V_{22}-V_{21}V_{11}^{-1}V_{12}&#92;&#92;  " class="latex" /></p>
<p>The post <a href="http://www.lindonslog.com/mathematics/invert-a-matrix-using-the-woodbury-matrix-inverse-formula-identity/">Invert a Matrix using the Woodbury Matrix Inverse Formula Identity</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.lindonslog.com/mathematics/invert-a-matrix-using-the-woodbury-matrix-inverse-formula-identity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Diagonalize a Positive-Definite Symmetric Matrix using the Schur Complement and LDU Decomposition</title>
		<link>http://www.lindonslog.com/mathematics/diagonalize-positive-definite-symmetric-matrix-schur-complement-ldu-decomposition/</link>
		<comments>http://www.lindonslog.com/mathematics/diagonalize-positive-definite-symmetric-matrix-schur-complement-ldu-decomposition/#comments</comments>
		<pubDate>Wed, 15 May 2013 19:49:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mathematics]]></category>

		<guid isPermaLink="false">http://www.lindonslog.com/?p=165</guid>
		<description><![CDATA[<p>Diagonalizing a matrix comes up frequently for me when wanting to diagonalize the variance matrix of a multivariate normal to derive conditional distributions. I prefer to proceed by doing an LDU Decomposition and leaving it in terms of the Schur complement as I find it easier to remember. Consider some matrix V and partition it [...]</p><p>The post <a href="http://www.lindonslog.com/mathematics/diagonalize-positive-definite-symmetric-matrix-schur-complement-ldu-decomposition/">Diagonalize a Positive-Definite Symmetric Matrix using the Schur Complement and LDU Decomposition</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Diagonalizing a matrix comes up frequently for me when wanting to diagonalize the variance matrix of a <a href="http://www.lindonslog.com/mathematics/multivariate-normal-conditional-distribution/" title="Multivariate Normal Conditional Distribution">multivariate normal to derive conditional distributions</a>. I prefer to proceed by doing an LDU Decomposition and leaving it in terms of the Schur complement as I find it easier to remember. Consider some matrix V and partition it as follows<br />
<img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D%3DV++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}=V  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}=V  " class="latex" /><br />
Consider right and left multiplying this matrix by<br />
<img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++1+%26+-V_%7B12%7DV_%7B22%7D%5E%7B-1%7D%5C%5C++++++++++0+%26+1%5C%5C++%5Cend%7Bpmatrix%7D++++%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D++++++++++++1+%26+0+%5C%5C++-V_%7B22%7D%5E%7B-1%7DV_%7B21%7D+%26+1+%5C%5C++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          1 &amp; -V_{12}V_{22}^{-1}&#92;&#92;          0 &amp; 1&#92;&#92;  &#92;end{pmatrix}    &#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            1 &amp; 0 &#92;&#92;  -V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          1 &amp; -V_{12}V_{22}^{-1}&#92;&#92;          0 &amp; 1&#92;&#92;  &#92;end{pmatrix}    &#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            1 &amp; 0 &#92;&#92;  -V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  " class="latex" /><br />
The matrices really correspond to the L and U matrices in the LDU decomposition, noting that the matrix on the right or left is just the transpose of the other. Define the Schur complement of the matrix V with respect to the block V22 as<br />
<img src="//s0.wp.com/latex.php?latex=V_%7B11.2%7D%3DV_%7B11%7D-V_%7B12%7DV_%7B22%7D%5E%7B-1%7DV_%7B21%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="V_{11.2}=V_{11}-V_{12}V_{22}^{-1}V_{21}  " title="V_{11.2}=V_{11}-V_{12}V_{22}^{-1}V_{21}  " class="latex" /><br />
then working through the above multiplication it follows that<br />
<img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++1+%26+-V_%7B12%7DV_%7B22%7D%5E%7B-1%7D%5C%5C++++++++++0+%26+1%5C%5C++%5Cend%7Bpmatrix%7D++++%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D++++++++++++1+%26+0+%5C%5C++-V_%7B22%7D%5E%7B-1%7DV_%7B21%7D+%26+1+%5C%5C++%5Cend%7Bpmatrix%7D++%3D++%5Cbegin%7Bpmatrix%7D+++++++++++V_%7B11.2%7D+%26+0+%5C%5C+++++++++++0+%26+V_%7B22%7D+%5C%5C+++%5Cend%7Bpmatrix%7D+++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          1 &amp; -V_{12}V_{22}^{-1}&#92;&#92;          0 &amp; 1&#92;&#92;  &#92;end{pmatrix}    &#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            1 &amp; 0 &#92;&#92;  -V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  =  &#92;begin{pmatrix}           V_{11.2} &amp; 0 &#92;&#92;           0 &amp; V_{22} &#92;&#92;   &#92;end{pmatrix}   " title="&#92;begin{pmatrix}          1 &amp; -V_{12}V_{22}^{-1}&#92;&#92;          0 &amp; 1&#92;&#92;  &#92;end{pmatrix}    &#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            1 &amp; 0 &#92;&#92;  -V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  =  &#92;begin{pmatrix}           V_{11.2} &amp; 0 &#92;&#92;           0 &amp; V_{22} &#92;&#92;   &#92;end{pmatrix}   " class="latex" /><br />
This result is useful in deriving the <a href="http://www.lindonslog.com/mathematics/invert-a-matrix-using-the-woodbury-matrix-inverse-formula-identity/">Sherman–Morrison–Woodbury matrix inverse formula/identity</a>, otherwise known as the matrix inversion lemma.<br />
One can now simply multiply the above equation by the corresponding inverse matrices to obtain the LDU decomposition of the matrix V. The inverse matrices are easy </p>
<p><img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++1+%26+V_%7B12%7DV_%7B22%7D%5E%7B-1%7D%5C%5C++++++++++0+%26+1%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D++++++++++1+%26+-V_%7B12%7DV_%7B22%7D%5E%7B-1%7D%5C%5C++++++++++0+%26+1%5C%5C++%5Cend%7Bpmatrix%7D++++%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D+++1+%26+0+%5C%5C++-V_%7B22%7D%5E%7B-1%7DV_%7B21%7D+%26+1+%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D++++++++++++1+%26+0+%5C%5C++V_%7B22%7D%5E%7B-1%7DV_%7B21%7D+%26+1+%5C%5C++%5Cend%7Bpmatrix%7D++%3D++%5Cbegin%7Bpmatrix%7D++++++++++1+%26+++++V_%7B12%7DV_%7B22%7D%5E%7B-1%7D+%5C%5C++++++0+%26+1%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D+++++++++++V_%7B11.2%7D+%26+0+%5C%5C+++++++++++0+%26+V_%7B22%7D+%5C%5C+++%5Cend%7Bpmatrix%7D+++%5Cbegin%7Bpmatrix%7D++++++++++++1+%26+0+%5C%5C++V_%7B22%7D%5E%7B-1%7DV_%7B21%7D+%26+1+%5C%5C++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          1 &amp; V_{12}V_{22}^{-1}&#92;&#92;          0 &amp; 1&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}          1 &amp; -V_{12}V_{22}^{-1}&#92;&#92;          0 &amp; 1&#92;&#92;  &#92;end{pmatrix}    &#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}   1 &amp; 0 &#92;&#92;  -V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            1 &amp; 0 &#92;&#92;  V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  =  &#92;begin{pmatrix}          1 &amp;     V_{12}V_{22}^{-1} &#92;&#92;      0 &amp; 1&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}           V_{11.2} &amp; 0 &#92;&#92;           0 &amp; V_{22} &#92;&#92;   &#92;end{pmatrix}   &#92;begin{pmatrix}            1 &amp; 0 &#92;&#92;  V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          1 &amp; V_{12}V_{22}^{-1}&#92;&#92;          0 &amp; 1&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}          1 &amp; -V_{12}V_{22}^{-1}&#92;&#92;          0 &amp; 1&#92;&#92;  &#92;end{pmatrix}    &#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}   1 &amp; 0 &#92;&#92;  -V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            1 &amp; 0 &#92;&#92;  V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  =  &#92;begin{pmatrix}          1 &amp;     V_{12}V_{22}^{-1} &#92;&#92;      0 &amp; 1&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}           V_{11.2} &amp; 0 &#92;&#92;           0 &amp; V_{22} &#92;&#92;   &#92;end{pmatrix}   &#92;begin{pmatrix}            1 &amp; 0 &#92;&#92;  V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  " class="latex" /><br />
So finally<br />
<img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D%3D++++%5Cbegin%7Bpmatrix%7D++++++++++1+%26++++V_%7B12%7DV_%7B22%7D%5E%7B-1%7D%5C%5C++0++++++%26+1%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D+++++++++++V_%7B11.2%7D+%26+0+%5C%5C+++++++++++0+%26+V_%7B22%7D+%5C%5C+++%5Cend%7Bpmatrix%7D+++%5Cbegin%7Bpmatrix%7D++++++++++++1+%26+0+%5C%5C++V_%7B22%7D%5E%7B-1%7DV_%7B21%7D+%26+1+%5C%5C++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}=    &#92;begin{pmatrix}          1 &amp;    V_{12}V_{22}^{-1}&#92;&#92;  0      &amp; 1&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}           V_{11.2} &amp; 0 &#92;&#92;           0 &amp; V_{22} &#92;&#92;   &#92;end{pmatrix}   &#92;begin{pmatrix}            1 &amp; 0 &#92;&#92;  V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}=    &#92;begin{pmatrix}          1 &amp;    V_{12}V_{22}^{-1}&#92;&#92;  0      &amp; 1&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}           V_{11.2} &amp; 0 &#92;&#92;           0 &amp; V_{22} &#92;&#92;   &#92;end{pmatrix}   &#92;begin{pmatrix}            1 &amp; 0 &#92;&#92;  V_{22}^{-1}V_{21} &amp; 1 &#92;&#92;  &#92;end{pmatrix}  " class="latex" /><br />
<img src="//s0.wp.com/latex.php?latex=V%3DUDL++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="V=UDL  " title="V=UDL  " class="latex" /><br />
Notice how this is a UDL factorization. It is entirely possible to do things a little differently and result with the LDU decomposition<br />
Consider right and left multiplying this matrix by<br />
<img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++1+%26+0%5C%5C++++++++++-V_%7B21%7DV_%7B11%7D%5E%7B-1%7D+%26+1%5C%5C++%5Cend%7Bpmatrix%7D++++%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D++++++++++++1+%26+-V_%7B11%7D%5E%7B-1%7DV_%7B12%7D+%5C%5C++0+%26+1+%5C%5C++%5Cend%7Bpmatrix%7D++%3D++%5Cbegin%7Bpmatrix%7D++++++++++++V_%7B11%7D+%26+0+%5C%5C++0+%26+V_%7B22.1%7D+%5C%5C++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          1 &amp; 0&#92;&#92;          -V_{21}V_{11}^{-1} &amp; 1&#92;&#92;  &#92;end{pmatrix}    &#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            1 &amp; -V_{11}^{-1}V_{12} &#92;&#92;  0 &amp; 1 &#92;&#92;  &#92;end{pmatrix}  =  &#92;begin{pmatrix}            V_{11} &amp; 0 &#92;&#92;  0 &amp; V_{22.1} &#92;&#92;  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          1 &amp; 0&#92;&#92;          -V_{21}V_{11}^{-1} &amp; 1&#92;&#92;  &#92;end{pmatrix}    &#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            1 &amp; -V_{11}^{-1}V_{12} &#92;&#92;  0 &amp; 1 &#92;&#92;  &#92;end{pmatrix}  =  &#92;begin{pmatrix}            V_{11} &amp; 0 &#92;&#92;  0 &amp; V_{22.1} &#92;&#92;  &#92;end{pmatrix}  " class="latex" /><br />
where<br />
<img src="//s0.wp.com/latex.php?latex=V_%7B22.1%7D%3DV_%7B22%7D-V_%7B21%7DV_%7B11%7D%5E%7B-1%7DV_%7B12%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="V_{22.1}=V_{22}-V_{21}V_{11}^{-1}V_{12}  " title="V_{22.1}=V_{22}-V_{21}V_{11}^{-1}V_{12}  " class="latex" /><br />
i.e. the Schur complement of matrix V with respect to block 11. So finally<br />
<img src="//s0.wp.com/latex.php?latex=%5Cbegin%7Bpmatrix%7D++++++++++V_%7B11%7D+%26+V_%7B12%7D%5C%5C++++++++++V_%7B21%7D+%26+V_%7B22%7D%5C%5C++%5Cend%7Bpmatrix%7D++++%3D++%5Cbegin%7Bpmatrix%7D++++++++++1+%26+0%5C%5C++++++++++V_%7B21%7DV_%7B11%7D%5E%7B-1%7D+%26+1%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D++++++++++++V_%7B11%7D+%26+0+%5C%5C++0+%26+V_%7B22.1%7D+%5C%5C++%5Cend%7Bpmatrix%7D++%5Cbegin%7Bpmatrix%7D++++++++++++1+%26+V_%7B11%7D%5E%7B-1%7DV_%7B12%7D+%5C%5C++0+%26+1+%5C%5C++%5Cend%7Bpmatrix%7D++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}    =  &#92;begin{pmatrix}          1 &amp; 0&#92;&#92;          V_{21}V_{11}^{-1} &amp; 1&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            V_{11} &amp; 0 &#92;&#92;  0 &amp; V_{22.1} &#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            1 &amp; V_{11}^{-1}V_{12} &#92;&#92;  0 &amp; 1 &#92;&#92;  &#92;end{pmatrix}  " title="&#92;begin{pmatrix}          V_{11} &amp; V_{12}&#92;&#92;          V_{21} &amp; V_{22}&#92;&#92;  &#92;end{pmatrix}    =  &#92;begin{pmatrix}          1 &amp; 0&#92;&#92;          V_{21}V_{11}^{-1} &amp; 1&#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            V_{11} &amp; 0 &#92;&#92;  0 &amp; V_{22.1} &#92;&#92;  &#92;end{pmatrix}  &#92;begin{pmatrix}            1 &amp; V_{11}^{-1}V_{12} &#92;&#92;  0 &amp; 1 &#92;&#92;  &#92;end{pmatrix}  " class="latex" /><br />
<img src="//s0.wp.com/latex.php?latex=V%3DLDU++&#038;bg=ffffff&#038;fg=000&#038;s=0" alt="V=LDU  " title="V=LDU  " class="latex" /></p>
<p>The post <a href="http://www.lindonslog.com/mathematics/diagonalize-positive-definite-symmetric-matrix-schur-complement-ldu-decomposition/">Diagonalize a Positive-Definite Symmetric Matrix using the Schur Complement and LDU Decomposition</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.lindonslog.com/mathematics/diagonalize-positive-definite-symmetric-matrix-schur-complement-ldu-decomposition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AWK Remove Lines of Multiple Files</title>
		<link>http://www.lindonslog.com/linux-unix/awk-remove-lines-of-multiple-files/</link>
		<comments>http://www.lindonslog.com/linux-unix/awk-remove-lines-of-multiple-files/#comments</comments>
		<pubDate>Sat, 16 Mar 2013 19:22:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux/Unix]]></category>

		<guid isPermaLink="false">http://www.lindonslog.com/?p=133</guid>
		<description><![CDATA[<p>My girlfriend is a statistician and acquired some data in the form of 200 text files. The problem is that each file had two lines of non-informative description which needed removing. The goal was to process the data to remove the descriptive header. Instead of removing the lines from every file, I wrote this for [...]</p><p>The post <a href="http://www.lindonslog.com/linux-unix/awk-remove-lines-of-multiple-files/">AWK Remove Lines of Multiple Files</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>My girlfriend is a statistician and acquired some data in the form of 200 text files. The problem is that each file had two lines of non-informative description which needed removing. The goal was to process the data to remove the descriptive header. Instead of removing the lines from every file, I wrote this for her</p>
<p><code><br />
mkdir news<br />
for file in *;<br />
do awk '{if (NR!=1 &#038;&#038; NR!=2) {print}}' "$file" > new_"$file";<br />
mv new_"$file" news/"$file";<br />
done </p>
<p>cd news;<br />
rm script;<br />
rm news;<br />
</code></p>
<p>This uses awk to remove lines 1 and 2 from all of the files in the current directory and store the reduced files in the newly created directory &#8220;news&#8221;. Just run the shell script in the directory containing all the files.</p>
<p>The post <a href="http://www.lindonslog.com/linux-unix/awk-remove-lines-of-multiple-files/">AWK Remove Lines of Multiple Files</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.lindonslog.com/linux-unix/awk-remove-lines-of-multiple-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Struct stat and stat()</title>
		<link>http://www.lindonslog.com/programming/struct-stat-and-stat/</link>
		<comments>http://www.lindonslog.com/programming/struct-stat-and-stat/#comments</comments>
		<pubDate>Sat, 19 Jan 2013 23:40:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.lindonslog.com/?p=52</guid>
		<description><![CDATA[<p>I came across this useful bit of code when wanting to read in some data from a text file. Suppose you do not know in advance how much data there is in a text file, how long should you make your buffer array to read the data into? The problem is you don&#8217;t know. You [...]</p><p>The post <a href="http://www.lindonslog.com/programming/struct-stat-and-stat/">Struct stat and stat()</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I came across this useful bit of code when wanting to read in some data from a text file. Suppose you do not know in advance how much data there is in a text file, how long should you make your buffer array to read the data into? The problem is you don&#8217;t know. You don&#8217;t want to make your buffer array neither too short and miss data, nor needlessly large.</p>
<p>You can use the stat() function to populate a structure containing information about a file, including its size, which you can then use to dynamically allocate memory. Here&#8217;s some example code:</p>
<pre>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>


int main(void){
    FILE *fp;
    char *buffer;
    struct stat statistics;
    fp = fopen("test.txt", "rb");
    stat("test.txt", &#038;statistics);
    buffer = (char *) malloc(statistics.st_size);
    fread(buffer, 1, statistics.st_size, fp);
    fclose(fp);  
}
</pre>
<p>First, you want to include the last two header files. Next you declare the struct stat structure where you want to store all the data. The stat() function takes two arguements. Number 1 being the file in question, number 2 the memory address of the structure where you want to store the information. So stat() will populate your structure. You can then call one of the members of this strucutre, statistics.st_size (which is of type off_t) to see how big in bytes the file is. Now a char is ALWAYS 1 byte, the standard says so, so you then allocate this number of bytes(==characters) for your array. fread() reads statistics.st_size objects, each of size 1, from fp and stores them in buffer. It advances the file position indicator by the number of bytes read.</p>
<p>The post <a href="http://www.lindonslog.com/programming/struct-stat-and-stat/">Struct stat and stat()</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.lindonslog.com/programming/struct-stat-and-stat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenMP Tutorial &#8211; firstprivate and lastprivate</title>
		<link>http://www.lindonslog.com/openmp/openmp-tutorial-firstprivate-and-lastprivate/</link>
		<comments>http://www.lindonslog.com/openmp/openmp-tutorial-firstprivate-and-lastprivate/#comments</comments>
		<pubDate>Sat, 19 Jan 2013 23:39:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenMP]]></category>

		<guid isPermaLink="false">http://www.lindonslog.com/?p=87</guid>
		<description><![CDATA[<p>Here I will consider firstprivate and lastprivate. Recall one of the earlier entries about private variables. When a variable is declared as private, each thread gets a unique memory address of where to store values for that variable while in the parallel region. When the parallel region ends, the memory is freed and these variables [...]</p><p>The post <a href="http://www.lindonslog.com/openmp/openmp-tutorial-firstprivate-and-lastprivate/">OpenMP Tutorial &#8211; firstprivate and lastprivate</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Here I will consider firstprivate and lastprivate. Recall one of the earlier entries about private variables. When a variable is declared as private, each thread gets a unique memory address of where to store values for that variable while in the parallel region. When the parallel region ends, the memory is freed and these variables no longer exist. Consider the following bit of code as an example:</p>
<pre>

#include <stdio.h>
#include <stdlib.h>
#include <omp.h>


int main(void){
int i;
int x;
x=44;
#pragma omp parallel for private(x) 
for(i=0;i<=10;i++){
x=i;
printf("Thread number: %d     x: %d\n",omp_get_thread_num(),x);
}
printf("x is %d\n", x);


}
</pre>
<p>Yields...</p>
<pre>

Thread number: 0     x: 0
Thread number: 0     x: 1
Thread number: 0     x: 2
Thread number: 3     x: 9
Thread number: 3     x: 10
Thread number: 2     x: 6
Thread number: 2     x: 7
Thread number: 2     x: 8
Thread number: 1     x: 3
Thread number: 1     x: 4
Thread number: 1     x: 5
x is 44
</pre>
<p>You'll notice that x is exactly the value it was before the parallel region.</p>
<p>Suppose we wanted to keep the last value of x after the parallel region. This can be achieved with lastprivate. Replace private(x) with lastprivate(x) and this is the result:</p>
<pre>

Thread number: 3     x: 9
Thread number: 3     x: 10
Thread number: 1     x: 3
Thread number: 1     x: 4
Thread number: 1     x: 5
Thread number: 0     x: 0
Thread number: 0     x: 1
Thread number: 0     x: 2
Thread number: 2     x: 6
Thread number: 2     x: 7
Thread number: 2     x: 8
x is 10
</pre>
<p>Notice that it is 10 and not 8. That is to say, it is the last iteration which is kept, not the last operation. Now what if we replace lastprivate(x) with firstprivate(x). What do you think it will do? This:</p>
<pre>
Thread number: 3     x: 9
Thread number: 3     x: 10
Thread number: 1     x: 3
Thread number: 1     x: 4
Thread number: 1     x: 5
Thread number: 0     x: 0
Thread number: 0     x: 1
Thread number: 0     x: 2
Thread number: 2     x: 6
Thread number: 2     x: 7
Thread number: 2     x: 8
x is 44
</pre>
<p>If you were like me, you were expecting to get the value 0 i.e. the value of x on the first iteration. <strong>NO</strong> </p>
<blockquote><p>firstprivate Specifies that each thread should have its own instance of a variable, and that the variable should be initialized with the value of the variable, because it exists before the parallel construct.</p></blockquote>
<p>That is, every thread gets its own instance of x and that instance equals 44.</p>
<p>The post <a href="http://www.lindonslog.com/openmp/openmp-tutorial-firstprivate-and-lastprivate/">OpenMP Tutorial &#8211; firstprivate and lastprivate</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.lindonslog.com/openmp/openmp-tutorial-firstprivate-and-lastprivate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rsync Tutorial and Help with Examples</title>
		<link>http://www.lindonslog.com/linux-unix/rsync-tutorial-and-help-with-examples/</link>
		<comments>http://www.lindonslog.com/linux-unix/rsync-tutorial-and-help-with-examples/#comments</comments>
		<pubDate>Sat, 19 Jan 2013 16:11:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux/Unix]]></category>

		<guid isPermaLink="false">http://www.lindonslog.com/?p=103</guid>
		<description><![CDATA[<p>rsync is what people used to use before Dropbox. It is used to sync remote folders with local ones. Say for example tha I have some work on my office computer in folder &#8216;foo&#8217;. It is the weekend and I need to work on this project but I don&#8217;t want to go into the office. [...]</p><p>The post <a href="http://www.lindonslog.com/linux-unix/rsync-tutorial-and-help-with-examples/">rsync Tutorial and Help with Examples</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>rsync is what people used to use before Dropbox. It is used to sync remote folders with local ones. Say for example tha I have some work on my office computer in folder &#8216;foo&#8217;. It is the weekend and I need to work on this project but I don&#8217;t want to go into the office. rsync can be used to pull the folder from the remote (office) machine onto my local (home) computer. Then, when I am done with the changes, rsync can push all the modified files back to the office computer. rsync has some really great features so that it will only transfer the files which have been modified. </p>
<pre>Home$ rsync -avzu office:.matlab/myfunctions/figs/ .
receiving incremental file list
./
1_a_0_neg.eps
1_a_0_pos.eps
1_a_10_neg.eps
1_a_10_pos.eps

sent 90 bytes  received 12464 bytes  2789.78 bytes/sec
total size is 36238  speedup is 2.89
</pre>
<p><strong>-a &#8211;archive</strong><br />
Stands for archive mode. Basically this means that the structure from the office machine is kept on the local machine (i.e. same symbolic links etc.)</p>
<p><strong>-v, &#8211;verbose</strong><br />
Increases verbosity</p>
<p><strong>-z, &#8211;compress</strong><br />
Compresses the files for transfer purposes and then uncompresses them on the local machine. Really great if transferring massive data.</p>
<p><strong>-u, &#8211;update</strong><br />
This means that if the destination folder has files with a timestamp which is newer than the files in the source folder, then the files in the destination folder will not be overwritten with the older source ones.</p>
<p>These are just a few most common arguments. Lastly, a good argument to remember</p>
<p><strong>-n, &#8211;dry-run</strong><br />
This won&#8217;t actually do any transfer of data, it merely shows you what rsync WOULD do if you removed this argument. A good choice if you want to be careful.</p>
<p>The post <a href="http://www.lindonslog.com/linux-unix/rsync-tutorial-and-help-with-examples/">rsync Tutorial and Help with Examples</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.lindonslog.com/linux-unix/rsync-tutorial-and-help-with-examples/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to crop a pdf when using the ps2pdf converter via -dEPSCrop</title>
		<link>http://www.lindonslog.com/linux-unix/ps2pdf-how-to-crop-the-white-border/</link>
		<comments>http://www.lindonslog.com/linux-unix/ps2pdf-how-to-crop-the-white-border/#comments</comments>
		<pubDate>Sat, 19 Jan 2013 14:48:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux/Unix]]></category>

		<guid isPermaLink="false">http://www.lindonslog.com/?p=97</guid>
		<description><![CDATA[<p>Often I find myself converting eps or ps to pdf files for inclusion in a latex document using the ps2pdf converter. The problem is that often when using ps2pdf I get a large white border around the figure of interest in my pdf file which was not included in the eps file. Obviously this is [...]</p><p>The post <a href="http://www.lindonslog.com/linux-unix/ps2pdf-how-to-crop-the-white-border/">How to crop a pdf when using the ps2pdf converter via -dEPSCrop</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Often I find myself converting eps or ps to pdf files for inclusion in a latex document using the ps2pdf converter. The problem is that often when using ps2pdf I get a large white border around the figure of interest in my pdf file which was not included in the eps file. Obviously this is annoying when trying to include the graphic in a latex file surrounded by text. The solution comes with using the -dEPSCrop option. </p>
<pre>lindon$ ps2pdf -dPDFSETTINGS=/prepress -dEPSCrop test.eps</pre>
<p>and now the pdf doesn&#8217;t included the unnecessary white space border.</p>
<p>The post <a href="http://www.lindonslog.com/linux-unix/ps2pdf-how-to-crop-the-white-border/">How to crop a pdf when using the ps2pdf converter via -dEPSCrop</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.lindonslog.com/linux-unix/ps2pdf-how-to-crop-the-white-border/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GNU Wget Tutorial</title>
		<link>http://www.lindonslog.com/linux-unix/gnu-wget-tutorial/</link>
		<comments>http://www.lindonslog.com/linux-unix/gnu-wget-tutorial/#comments</comments>
		<pubDate>Fri, 06 Jul 2012 14:15:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux/Unix]]></category>

		<guid isPermaLink="false">http://www.lindonslog.com/?p=91</guid>
		<description><![CDATA[<p>As a student, you may find yourself wanting to download lots of lecture slides and other materials off a module homepage, which can become quite an arduous task. Thankfully, GNU created Wget which is already on most linux machines. It is best demonstrated by example: wget -r -l5 -np -k -nH --cut-dirs=5 --load-cookies cookies.txt http://www2.warwick.ac.uk/fac/sci/physics/current/teach/module_home/px421/ [...]</p><p>The post <a href="http://www.lindonslog.com/linux-unix/gnu-wget-tutorial/">GNU Wget Tutorial</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>As a student, you may find yourself wanting to download lots of lecture slides and other materials off a module homepage, which can become quite an arduous task. Thankfully, GNU created Wget which is already on most linux machines. It is best demonstrated by example:</p>
<pre>
wget -r -l5 -np -k -nH --cut-dirs=5 --load-cookies cookies.txt http://www2.warwick.ac.uk/fac/sci/physics/current/teach/module_home/px421/
</pre>
<p>-r<br />
Means wget acts <em>recursively</em> i.e. it follows links found on the current page (much like a search engine spider.</p>
<p>-l<br />
Specifies the <em>depth</em>, which means how many of these links it can follow. If you imagine all the links on the current page forming branches away from it, then the links on those pages forming branches away from those, then -l5 sets the maximum branch distance away from the current page.</p>
<p>-np<br />
<em>No Parent</em>, means wget will only progress down the directory tree i.e. it will not work its way back into http://www2.warwick.ac.uk/fac/sci/physics/current/teach/module_home/</p>
<p>-k<br />
<em>Convert Hyperlinks</em>. When wget downloads a page, say index.html, there will be links on that page just like viewed in your browser but -k will convert them to local links, so that you can navigate your way through the pages on your local machine.</p>
<p>-nH<br />
<em>No host directories</em>. Basically wget would otherwise create a folder named &#8220;http://www2.warwick.ac.uk/&#8221; and all the downloaded stuff would get stored in there, which is normally undesirable.</p>
<p>&#8211;cut-dirs=5<br />
Otherwise wget would create 5 directories<br />
<code></p>
<p>http://www2.warwick.ac.uk/fac/</p>
<p>sci/<br />
physics/<br />
current/<br />
teach/<br />
module_home/<br />
</code><br />
in a directory tree which you don&#8217;t want to have to click through&#8230;</p>
<p><em>&#8211;load-cookies</em><br />
Normally content is restricted and you need to login, so you need to supply wget with some cookies. If you are a firefox user then there is an extension called &#8216;cookie exporter&#8217;, which you can use to output your cookies to a file called cookies.txt.</p>
<p>That&#8217;s it! </p>
<p>The post <a href="http://www.lindonslog.com/linux-unix/gnu-wget-tutorial/">GNU Wget Tutorial</a> appeared first on <a href="http://www.lindonslog.com">Lindons Log</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.lindonslog.com/linux-unix/gnu-wget-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
