Calculating Partitioned Matrices from subs Say you have a matrix $A$ which is of size $P\times P$ and a number $Q < P$ can be used to
take a partition of said matrix, where:


*

*$A_1$ is the upper-left sub matrix, with dimension $Q\times Q$,

*$A_2$ is the upper-right sub matrix, with dimension $Q\times(P-Q)$,

*$A_3$ is the lower-left sub matrix, with dimension $(P-Q)\times Q$,

*$A_4$ is the lower-rightsub matrix, with dimension $(P-Q)\times(P-Q)$.


Which looks like this: 
$$A=\begin{pmatrix}A_1& A_2\\A_3&A_4\end{pmatrix}$$
How can you calculate the matrix:

Where $0_q$ is a $Q\times Q$ matrix with zero elements. 
I'm learning from a book called "Discovering Statistics using R" and although it discusses partitioned matrices, it doesn't show how to calculate one like the one given above and unfortunately I'm having no luck on the programming or maths based searches...
Any help, either mathematically and/or example R code would be great. Thanks in advance.
 A: Assuming that $A$ is symmetric (which can be checked in advance easily if not assumed a priori), you can do the following:
Compute the $LDL^T$ factorization of $A_4$, that is, find a unit lower triangular matrix $L_4$ and a diagonal matrix $D_4$ such that $A_4=L_4D_4L_4^T$. If $A$ is SPD, then $D_4$ must have positive diagonal elements. If some non-positive pivot occurs during the factorization, the matrix $A$ is certainly not SPD.
Then compute $B$: $B=A_1-(A_2L_4^{-T})D_4^{-1}(L_4^{-1}A_4)=A_1-C_2D_4^{-1}C_4$. Note that in order to compute $C_2=A_2L_4^{-T}$ and $C_4=L_4^{-1}A_4$, you don't need (and should not) compute the inverse of $L_4$. Instead, you can consider it as solving two systems with multiple right-hand sides
$$
L_4^TC_2=A_2,\qquad L_4C_4=A_4,
$$
and perform a bunch of forward and backward substitutions to obtain $C_2$ and $C_4$.
The matrix $A$ is SPD iff $A_4$ and $B$ are SPD. So if you want to check further that $A$ is SPD, you can compute the $LDL^T$ factorization of $B$ again and verify that there is no non-positive pivot in the diagonal factor.
Note: You can probably use directly the Cholesky factorization provided that the routine you have in R can safely handle the failure (non-positive pivots).
