Check The Programming Section
The transpose of a matrix A, denoted by AT, may be constructed by any one of the following methods:
Write the rows of A as the columns of AT;
Write the columns of A as the rows of AT.
Formally, the i-th row, j-th column element of AT is the j-th row, i-th column element of A:
AT[j,i] = A[i, j]
If A is an m × n matrix, then AT is an n × m matrix. For example,
If the given matrix is
1 2 3
4 5 6
7 8 9
The traspose matrix will be
1 4 7
2 5 8
3 6 9