Table[ math[k, q],  {k,  0,  2},  {q,  -k,  k}];

mattkq[0, 
              0]  =  {{1,  0,  0},  {0,  1,  0},  {0,  0,  1}}/
              Sqrt[3];
mattkq[1, 0]  =  
            I*{{0,  1,  0},  {-1,  0,  0},  {0,  0,  0}}/
                Sqrt[2];
mattkq[1, 
              1]  =  {{0,  0,  -1},  {0,  0,  -I},  {1,  
                  I,  0}}/2;
mattkq[
              1, -1]  =  {{0,  0,  -1},  {0,  0, 
                  I},  {1,  -I,  0}}/2;
mattkq[2, 
              0]  =  {{-1,  0,  0},  {0,  -1,  0},  {0,  
                  0,  2}}/Sqrt[6];
mattkq[2, 
              1]  =  -{{0,  0,  1},  {0,  0,  I},  {1,  I,  0}}/
              2;
mattkq[
              2, -1]  =  {{0,  0,  1},  {0,  
                  0,  -I},  {1,  -I,  0}}/2;
mattkq[2, 
              2]  =  {{1,  I,  0},  {I,  -1,  0},  {0,  0,  0}}/
              2;
mattkq[
              2, -2]  =  {{1,  -I,  0},  {-I,  -1,  
                  0},  {0,  0,  0}}/2;
  
\(For\ [k = 0, \ k < 3, \ 
          k = k + 1, \ 
\ \ \ \ \ \ For\ [q = \(-k\), \ 
            q < \ k + 1, \ 
            q = 
              q + 1, \ 
\ \ \ \ \ \ \ \ \ \ \ \ Print["-----------------------"]
\ \ \ \ \ \ \ \ \ \ Print["k = ", \ k, \ ", q = ", \ 
                q]
\ \ \ \ \ \ \ \ \ \ Print[
                MatrixForm[
                  mattkq[k, 
                    q]]]
\ \ \ \ ]
]\)
  
For [k = 0, k < 3, k = k + 1, 
      For [q = -k, q <  k + 1, q = q + 1, 
            For [r = 0, r < 3, r = r + 1, 
                  For [s = -r, s <  r + 1, s = s + 1, 
                        tt  = 
                            Transpose[mattkq[k, q]]  .  mattkq[r, s];
                        trax = 
                            tt[[1, 1]] + tt[[2, 2]] + 
                              tt[[3, 3]];
                        If [trax  !=  0, 
                            {
                            \(Print["-----------------------"]\);
                            Print["k = ", k, ", q = ", q, ", r = ", r, ", s = ", s];
                            Print["First definition of double dot product"];
                            Print[
                                    MatrixForm[tt]];
                            Print["trace = ", trax]; 
                            Print["---------"];
                            tt  = 
                                    mattkq[k, q]  .  mattkq[r, s];
                            trax = 
                                    tt[[1, 1]] + tt[[2, 2]] + 
                                      tt[[3, 3]];
                            Print["Second definition of double dot product"];
                            Print[
                                    MatrixForm[tt]];
                            Print["trace = ", trax]; 
                           }
                     ];
                 ]
            ]
     ]
]