Find unitary transformation between two sets of matrices that represent group generators I have a set of matrices $A_i$ that represent the generators of a finite group within a certain basis, and $B_i$ represent the same operators in a different basis.
How can I find a unitary transformation $U$ that performs this change of basis, so that $U A_i U^{-1} = B_i$ for all $i$? All I have are the matrices $A_i$ and $B_i$ and I need $U$.
For a single pair $A_1$ and $B_1$ it would be easy (as discussed here):

Let $P$ and $S$ be unitary matrices that diagonalize $A_1$ and $B_1$. Then $U A_1 U^{-1} = B_1$ is solved for $U=SP^{-1}$.

But this does not guarantee that the same $U$ will do the trick for all $A_i$ and $B_i$.
 A: I've found a practical solution. But I still wonder if there's a more elegant and algebraic solution for this problem. In any case, here's my approach:
Let's consider that each $A_i$, $B_i$ and $U$ are $N\times N$ matrices, and there are $M$ pairs ($A_i, B_i$), i = 1...M. The proof that exists a common $U$ matrix that satisfies $U A_i U^{-1} = B_i$ for all $i$ follows from (finite) group theory, since $A_i$ and $B_i$ are simply different matrix representations of the same symmetry operator.
Start by linearizing (flatten) the matrix $U$ into a vector $\vec{U}$ in "Z"-order (line-by-line). Namely,
$$\vec{U}^T = [U_{11}, U_{12}, U_{13}, \cdots, U_{2,1}, U_{2,2}, \cdots U_{N,N}].$$
Now rewrite the set of equations $U A_i U^{-1} = B_i$ as $U A_i - B_i U = 0$, which can be cast in the linearized form as
$$Q \cdot \vec{U} = 0.$$
Here $Q$ is an $(N^2M) \times N^2$ rectangular matrix that can be written in terms of $N^2 \times N^2$ blocks for each $i$ as:
$$Q^T = [Q_1, Q_2, \cdots, Q_M],$$
and each block read as
$$Q_i = I \otimes A_i^T - B_i \otimes I.$$
Now, to find $\vec{U}$ we simply need to look for $Q$'s nullspace, or find the right SVD eigenvector with a zero singular value. This vector $\vec{U}$ can then be reshaped into the unitary matrix $U$.
