Next: t2int() Up: MacAnova Help File Previous: syntax   Contents


t(x) is same as x', x a vector, matrix, array or structure
t(x,J), x an array or structure, and J a vector containing a permutation
  of run(p)

Keywords: matrix algebra, operations
t(x), where x is a vector, matrix, array or a structure, is equivalent
to x'.  See topic 'transpose'.

y <- t(x, J), where x is an array with p dimensions and J is an integer
vector containing a permutation of run(p), sets y to a copy of x with
the dimensions permuted.  y is an array with dimensions dim(x)[J] and,
when I is a vector of p integers with 1 <= I[j] <= dim(x)[J[j]],
  y[I[1],I[2],...,I[p]] = x[I[J[1]], I[J[2]],..., I[J[p]]].

For example, when x has three dimensions, and J = vector(3,1,2),
dimension 1 of y is dimension 3 of x, dimension 2 of y is dimension 1 of
x, and dimension 3 of y is dimension 2 of x.

t(x,j1,j2,...,jk) is equivalent to t(x,vector(j1,j2,...,jk)), where j1,
..., jk are scalars or vectors.

When p >= 2, t(x,run(p,1)) is equivalent to t(x) and x'.  When p = 1,
t(x) and x' are 2 dimensional with one row, but t(x,run(2,1)) is
illegal, since length(J) = 2 != ndims(x) = 1.

When x is a structure, all of whose non-structure components are arrays
with the same number of dimensions, t(x,J) is a structure of the same
shape and with the same component names as x, with each non-structure
component a copy of the corresponding component of x with dimensions

  Cmd> x <- array(run(24),4,3,2) # x has dimensions 4, 3, 2

  Cmd> y <- t(x,vector(3,1,2)) # y has dimensions 2, 4, 3

  Cmd> i1 <- 2; i2 <- 2; i3 <- 3;vector(y[i1,i2,i3],x[i2,i3,i1])
  (1)          22          22

  Cmd> i1 <- 1; i2 <- 4; i3 <- 2;vector(y[i1,i2,i3],x[i2,i3,i1])
  (1)           8           8

See also topics array(), 'vectors', 'matrices', 'subscripts'.

Gary Oehlert 2003-01-15