APLX Help : Help on APL language : APL Primitives : ⍉ Transpose




Monadic (oneargument) form:Transpose reverses the order of the axes of an array. Thus the first row of a matrix becomes the first column and vice versa, and similarly for arrays of more dimensions. It has no effect on scalars or vectors. TABLE 1 2 3 6 7 8 ⍉ TABLE 1 6 2 7 3 8 ⍉ 1 2 3 1 2 3 (Has no effect on a vector) DATA ← 12 4 9 ⍴ ⍳ 432 ⍴ DATA 12 4 9 ⍴ ⍉ DATA 9 4 12 DATA[1;;2]=(⍉DATA)[2;;1] 1 1 1 1 Dyadic (twoargument) form:Changes the order of the rows and columns in the righthand argument according to instructions in the lefthand argument and selects a subset of the right argument. There must be as many elements in the left argument as there are dimensions in the right. This operation has most effect when applied to data which has more than two dimensions. There must be a number in the lefthand argument for each dimension of the result. The result can have any rank greater than zero and not greater than the right argument. Thus for a rank 3 result you must have the numbers 1 2 3 appearing at least once each in the left argument. The positions of the values within the left argument correspond to the axes of the right argument and the values of the left argument refer to the axes of the result. There are two cases to consider. The first is where all numbers in the left argument are unique. In this case all axes (and all elements) of the right argument appear in the result. TABLE 1 2 3 6 9 10 2 1 ⍉ TABLE (First element of left argument shows that 1 3 9 axis 1 of TABLE becomes axis 2 of result. 2 6 10 Same as one argument ⍉) 1 2 ⍉TABLE (Coordinates stay in their original 1 2 order so matrix is unchanged) 3 6 9 10 ⍴DATA 12 4 9 ⍴3 1 2⍉DATA (1st axis of DATA becomes 3rd axis of 4 9 12 result, 2nd axis of DATA the 1st, etc) DATA[10;3;7]=(3 1 2⍉DATA)[3;7;10] 1 When there are repetitions within the left argument, then the appropriate axes of the right argument will be mapped together and the rank of the result will be less than that of the right argument. Thus if the left argument to TABLE1 1 2 3 4 1 1 ⍉ TABLE1 (Result is those elements whose row and 1 4 column positions match  [1;1] and [2;2]) ⍴DATA 12 4 9 ⍴1 2 1⍉DATA 9 4 DATA[4;3;4]=(1 2 1⍉DATA)[4;3] 1 If the axes that are being mapped together are of different lengths, those positions that are common are only as many as the length of the shortest axis. Transpose can be used in selective specification. 

APLX Help : Help on APL language : APL Primitives : ⍉ Transpose

Copyright © 19962010 MicroAPL Ltd