transpose
The transpose operator reverses the order of the dimensions. Â For a 2-dimensional array, this is equivalent to matrix transpose.
Synopsis
transpose(array)
Summary
Given an array containing dimensions d1, d2, ... , dn the result contains the dimensions in reverse order dn, ... , d2, d1.
Example
To transpose a 3×2 array:
Create the array and give each cell's attribute a unique value:
AFL% create array M <val:double>[a=0:2; b=0:1]; AFL% store(build(M, a*2+b), M);
The output is:{a,b} val {0,0} 0 {0,1} 1 {1,0} 2 {1,1} 3 {2,0} 4 {2,1} 5
Â
Transpose M:
AFL% transpose(M); Â
The output is:{b,a} val {0,0} 0 {0,1} 2 {0,2} 4 {1,0} 1 {1,1} 3 {1,2} 5
Note that the array changed from being 3x2 to 2x3, and how the attribute order changes from (a,b) to (b,a).
Â