Transpose of a Matrix

The transpose of a matrix A is another matrix image.   The general formula for a matrix transposition is

image

For example,

200px-Matrix_transpose

A square matrix whose transpose is equal to itself is called a symmetric matrix; that is, A is symmetric if

image

Here is the C++ implementation of matrix transposition.  The complete source code of CMatrix can be downloaded from here.

template
CMatrix
CMatrix::transpose() const
{
    CMatrix mat(_columns, _rows);
    for (int i = 0; i < _rows; i++)
        for (int j = 0; j < _columns; j++)
            mat.get(j, i) = get(i, j);

    return mat;
}

Leave a Reply