I'm very new with representations of groups.
Here it is a non-commutative group with $6$ elements defined by $D_3 = \langle p,q\ |\ p^3 = q^2 = (pq)^2 = 1\rangle$
The representation I'm interested in is the permutation matrix representation $$P = {\scriptstyle\begin{pmatrix} 0 & 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0\\ 1 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 & 0\end{pmatrix}},\qquad Q = \scriptstyle\begin{pmatrix} 0 & 1 & 0 & 0 & 0 & 0 \\ 1 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 1\\ 0 & 0 & 0 & 0 & 1 & 0\end{pmatrix}$$
From which I would like to find a matrix $T$ such that for any $X \in \langle P, Q \rangle$ I have $$T X T^{-1} = \scriptstyle\begin{pmatrix} \rho_1(X) & \\ & \rho_2(X) \\ & & \rho_3(X) \\ & & & \rho_4(X)\end{pmatrix}$$ where $\rho_i$ are the irreducible representations.
Is there a way to achieve this using Sage, Magma or Gap ?
(Note : I'm interested in the Artin L-functions of $K/\mathbb{Q}$ where $K$ is a Galois number field with Galois group $D_3$, and $T$ is supposed to help understanding how the representations could act on the field)
This is basically a two-stage process. First we compute (in the representation you have) the idempotents for the different irreducible representations. They are given by the formula $$ e_\chi=\frac{1}{|G|}\sum_{g\in G} \chi(g)g^{-1} $$ Multiplication with the idempotents will map into the homogeneous component for the representation, that is the row space of each idempotent is a basis for the homogeneous component for the representation.
In GAP, you would construct the matrix group (also could use homomorphism from permutations to matrices instead), and calculate the irreducible characters:
Next we determine the elements of the group and the classes they lie in
This gives us three matrices of rank $1^2$, $2^2$ and $1^2$. Their row spaces are bases for the homogeneous components for each representation. We guess that the first 4 rows of the second matrix are independent and do a base change, this gives (we also swap representations 2 and 3 to get the arrangement you want):
Now the 1-dimensional representations are OK, but the last block has the 2-dimensional representation twice. To split this up we need to find a vector in a submodule. (The method is essentially what goes by the name of MeatAxe):
I will not describe the general method here, but just observe that an eagle-eyed view of the two matrices shows that the vector $(0,0,1,1,0,0)$ has orbit length under the group generated by the two matrices and lies in a 2-dimensional subspace. Complementing this submodule and doing the base change gives:
Now vectors 3 and 4 also span a submodule, but 5 and 6 do not yet. The proof of Maschke's theorem will give a general way to fix this, but as I'm lazy I observe that we could instead do the same with the vector $(0,0,0,0,1,1)$ to span another 2-dimensional subspace.
To go from your original representation both base changes need to be combined, indeed it works as desired: