Transposing a matrix by similarity operations