# Moore - Penrose pseudoinverse of a general block matrix

How would Moore-Penrose pseudoinverse look like for a simple general example of a block matrix?

$$A_1=\begin{pmatrix} X & 0 \\ 0 & 0 \\ \end{pmatrix}$$ $$A_2=\begin{pmatrix} 0 & X \\ 0 & 0 \\ \end{pmatrix}$$

Where X is a block matrix.

I tried some online calculator and got:

$$A^+_1=\begin{pmatrix} X^+ & 0 \\ 0 & 0 \\ \end{pmatrix}$$ $$A^+_2=\begin{pmatrix} 0 & 0 \\ X^+ & 0 \\ \end{pmatrix}$$

Where $$A_i^+$$ and $$X^+$$ denote the pseudoinverses.

But why there is the flip for $$A_2$$? Because of the transposition?

Is there any general formula how to deal with the block matrices like this?

On Wikipedia I just found the block matrices written in the form of $$A = (X | Y)$$ or the general expression for the inverse of the block matrices but I wasnt able to find out why that flip actually happened in these formulae.

And what if $$X$$ isn't regular or square?

Recall that $$A^+$$ is the unique matrix such that $$AA^+A=A,\,A^+AA^+=A^+$$ and both $$AA^+$$ and $$A^+A$$ are Hermitian. So, if $$P$$ is a permutation such that the product $$AP$$ makes sense, then $$(AP)(P^TA^+)(AP)=AP,\,(P^TA^+)(AP)(P^TA^+)=P^TA^+$$ and both $$(AP)(P^TA^+),\,(P^TA^+)(AP)$$ are Hermitian. It follows that $$(AP)^+=P^TA^+$$. That is, if you permute the columns of $$A$$, the rows of $$A^+$$ will be permuted too.
There is actually a special case of the more general result that $$(AB)^+=B^+A^+$$ when $$B$$ has orthonormal rows.