math: matrix_to_tr function added