Generalized transpose of an array



next up previous contents
Next: Matrix facilities. Multiplication Up: Arrays and matrices Previous: An example: Determinants

Generalized transpose of an array

The function aperm(a, perm) may be used to permute an array, a. The argument perm must be a permutation of the integers 1, 2, ..., k, where k is the number of subscripts in a. The result of the function is an array of the same size as a but with old dimension given by perm[j] becoming the new jth dimension. The easiest way to think of this operation is as a generalization of transposition for matrices. Indeed if A is a matrix, (i.e. a doubly subscripted array) then B given by

B <- aperm(A, c(2,1))

is just the transpose of A. For this special case a simpler function t() is available, so we could have used B <- t(A).



Erik Moledor
Tue Jan 31 21:02:18 EST 1995