I am trying to write a program of the following nature. Let $A = [[a_{ij}]]$ be a $4 \times 4$ matrix. I have to divide it in the form
$$ A = \begin{bmatrix} P & Q \\ R & S\end{bmatrix}$$
where $P,Q,R,S$ are all $2 \times 2$ matrices. Now I want to apply an arbitrary map on this form. For a concrete example let the map be $f\left(\begin{bmatrix} a & b \\ c & d \end{bmatrix} \right) = \begin{bmatrix} a-d & b-c \\ c-b & d+a \end{bmatrix}$, which applied on the actual matrix should be of the form $$ f(A) = \begin{bmatrix} P -S & Q-R \\ R-Q & S+P\end{bmatrix}.$$ The output should be seen in the form of a $4\times 4$ matrix. All these can be done by hand of course.
Of course the matrix which I want to work on is very large (and may not admit a $2 \times 2$ block matrix form). Similarly the function $f$ may be equally complicated so much so that entrywise manipulation may not be easy. Is there any easy way to do all these? Advanced thanks for any help or suggestion.