Let $A$ be a real, full rank, block-diagonal matrix with $K$ $M$ by $M$ blocks on its diagonal.
Let $B$ be a real, full rank, block-diagonal matrix with $M$ $K$ by $K$ blocks on its diagonal.
Let $P$ be any permutation matrix.
Is there a smart way of calculating the inverse of the matrix $C := A + P B P^T$? Basically, I am wondering if there are any tricks that will allow me to leverage the fact that the inverses $A^{-1}$ and $P B^{-1} P$ can be calculated quite efficiently.
I would also be happy to assume that $A$ and $B$ are symmetric or positive-definite, if that is of any help. Similar questions here seem to use some version of the Sherman-Morrison formula, but it does not seem to help in this case, since both matrices are full rank.
I also found this question. However, I feel that the additional structure given by the fact that $P B P^{T}$ is a permuted block matrix might help. In any case, the answer to that question certainly has some flaws that could be revealed using simple 2D counter-examples. Unfortunately, I do not have the reputation yet to be allowed to comment, but I would be happy to formulate a comment if somebody would like to post it.