I have a large block arrowhead matrix which has significant sparsity in the following pattern:
$\mathbf{M} = \left( \begin{array}{c|c} \mathbf{A} & \mathbf{B}^{\top}\\ \hline \mathbf{B} & \mathbf{D} \end{array} \right) = \left( \begin{array}{cccc|cc} \mathbf{A}_1 & & & & \mathbf{B}_1^{\top} \\ & \mathbf{A}_2 & & & \mathbf{B}_2^{\top} \\ & & \ddots & & \vdots \\ & & & \mathbf{A}_n & \mathbf{B}_n^{\top} \\ \hline \mathbf{B}_1 & \mathbf{B}_2 & \dots & \mathbf{B}_n & \mathbf{D} \end{array} \right)$
where $\text{det}(\mathbf{M}) \neq 0, \text{det}(\mathbf{A}) \neq 0 \text{ and }\text{det}(\mathbf{D}) \neq 0$. $\mathbf{A}$ is a block diagonal square matrix comprsing of the blocks $\mathbf{A}_1, \mathbf{A}_2, \dots, \mathbf{A}_n$ which are all invertible, square matrices. $\mathbf{D}$ and $\mathbf{M}$ are square matrices as well.
My objective is to figure out an efficient technique for computing $\mathbf{M}^{-1}$, which is a well-known problem. But, for some reason, I do not get the correct inversion. Any help in figuring out my mistake would be hugely appreciated.
I do the following to compute the matrix inverse:
$\mathbf{M}^{-1} = \begin{pmatrix} \mathbf{A}^{-1} + \mathbf{A}^{-1}\mathbf{B}^{\top}(\mathbf{D} - \mathbf{B}\mathbf{A}^{-1}\mathbf{B}^{\top})^{-1}\mathbf{B}\mathbf{A}^{-1} & -\mathbf{A}^{-1}\mathbf{B}^{\top}(\mathbf{D} - \mathbf{B}\mathbf{A}^{-1}\mathbf{B}^{\top})^{-1} \\ -(\mathbf{D} - \mathbf{B}\mathbf{A}^{-1}\mathbf{B}^{\top})^{-1}\mathbf{B}\mathbf{A}^{-1} & (\mathbf{D} - \mathbf{B}\mathbf{A}^{-1}\mathbf{B}^{\top})^{-1} \end{pmatrix}$
since the Schur complement of $\mathbf{A}$ in $\mathbf{M}$ also appears to be invertible. I do not use an efficient inversion of $\mathbf{A}^{-1}$ for now, which could possibly be done by inverting the blocks $\mathbf{A}_1, \mathbf{A}_2, \dots, \mathbf{A}_n$.
However, the problem is, after computing the inverse in such a manner, I get $\mathbf{M}\mathbf{M}^{-1} \neq \mathbf{M}^{-1}\mathbf{M} \neq \mathbf{I}$, where $\mathbf{I}$ is the identity matrix. I notice some very large values in the last few rows of $\mathbf{M}\mathbf{M}^{-1}$. Clearly, I am doing something wrong.
Please help me identify my mistake. Thanks in advance.