Block diagonalization of matrix via congruence transformation

154 Views Asked by At

I have multiple square (and mostly also symmetric) matrices $A_n$ with various dimensions $n$ and I know that some of them are related to each other via a congruence transformation $PA_nP^T = \text{diag}(A_i,A_j,\dots)$ where $i + j + \dots = n$. The right hand side is given by a block diagonal combination of the given matrices. The elements of all matrices involved are integers. Is there an algorithm which allows me to easily calculate the transformation matrix $P$?