For a two dimensional matrix, mA (declared mA[N,M] in C/C++ or mA(0 to M-1,0 to N-1) in VB), the transposed return matrix mB (rows and columns switched, mB[M,N] in C/C++ or mA(0 to N-1,0 to M-1) in VB) is created so that:
mB[m,n] = mA[n,m] for m, 0 to M-1, and n, 0 to N-1. (C/C++ syntax)
mB(n,m) = mB(m,n) for m, 0 to M-1, and n, 0 to N-1. (VB syntax)
Note that for arrays of 2 or more dimensions, for the same layout in memory, the ordering of dimensions is different in VB from that used in C/C++. In VB, the fastest moving dimension (the row dimension, whose elements are adjacent in memory) is the leftmost. In C/C++, the fastest moving dimension is the rightmost.
For objects with more than two dimensions, the transpose function can perform a general transposition of any or all dimensions. By default, the transposed order of all dimensions is reversed. That is, a 4-D object declared vA[N,M,L,K] (C/C++ ordering) would, by default, be transposed into a 4-D object effectively declared vB[K,L,M,N] (C/C++ ordering), where each element vB[k,l,m,n] is set from the corresponding element vA[n,m,l,k]. A transposition ordering other than the default can be specified by giving an array of dimension numbers in the destination object in the order they are to be taken from the source object.
The operation of the McTranspose method is sometimes difficult to visualize, especially for objects with more than two dimensions. However, the method is worth some investment in learning, because it can allow vector operations to replace what would otherwise be possible only by writing an explicit loop for stepping through the elements of some dimension.
Example 2 is an illustrations of this sort of use for the Transpose function. The key concept here is to remember that the association rules for binary operations (such as the McOpAdd operation in the example) operate as if both operands were un-wound into simple 1-D arrays. A transposition operation may be necessary to move the dimension you want to operate along into the fastest-moving position; a second transposition can be used to put it back in its original place (as in the example).