Jump to content

In-place matrix transposition

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Stevenj (talk | contribs) at 17:26, 11 May 2007 (new article, still somewhat stubby). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

In-place matrix transposition, also called in-situ matrix transposition, refers to the problem of transposing an matrix in-place in computer memory: with additional storage, or at most with additional storage much less than . Typically, the matrix is assumed to be stored in row-major order or column-major order (i.e., contiguous rows or columns, respectively, arranged consecutively).

The problem is most difficult when , i.e. for a non-square (rectangular) matrix, where it involves a complicated permutation of the data elements, with many cycles of length greater than 2. In contrast, for a square matrix (), all of the cycles of are length 1 or 2, and the transposition can achieved by a simple loop to swap the upper triangle of the matrix with the lower triangle. Further complications arise if one wishes to maximize memory locality, however, to improve cache line utilization, since transposes naturally require non-consecutive memory accesses.

The problem of non-square in-place transposition has been studied since at least the late 1950s, and several algorithms are known, including several which attempt to optimize locality for cache optimization.

References