Joint Approximate Diagonalization of a set of square matrices