In-place Matrix Transposition - Example

Example

For example, consider the 2×4 matrix:

In row-major format, this would be stored in computer memory as the sequence (10, 11, 12, 13, 14, 15, 16, 17), i.e. the two rows stored consecutively. If we transpose this, we obtain the 4×2 matrix:

which is stored in computer memory as the sequence (10, 14, 11, 15, 12, 16, 13, 17).

Position 0 1 2 3 4 5 6 7
Original storage 10 11 12 13 14 15 16 17
Transposed storage 10 14 11 15 12 16 13 17

If we number the storage locations 0 to 7, from left to right, then this permutation consists of four cycles:

(0), (1 2 4), (3 6 5), (7)

That is, the value in position 0 goes to position 0 (a cycle of length 1, no data motion). And the value in position 1 (in the original storage: 10, 11, 12, 13, 14, 15, 16, 17) goes to position 2 (in the transposed storage 10, 14, 11, 15, 12, 16, 13, 17), while the value in position 2 (10, 11, 12, 13, 14, 15, 16, 17) goes to position 4 (10, 14, 11, 15, 12, 16, 13, 17), while position 4 (10, 11, 12, 13, 14, 15, 16, 17) goes back to position 1 (10, 14, 11, 15, 12, 16, 13, 17). Similarly for the values in position 7 and positions (3 6 5).

Read more about this topic:  In-place Matrix Transposition

Famous quotes containing the word example:

    Our intellect is not the most subtle, the most powerful, the most appropriate, instrument for revealing the truth. It is life that, little by little, example by example, permits us to see that what is most important to our heart, or to our mind, is learned not by reasoning but through other agencies. Then it is that the intellect, observing their superiority, abdicates its control to them upon reasoned grounds and agrees to become their collaborator and lackey.
    Marcel Proust (1871–1922)