permute -- permute the dimensions of a multidimensional matrix

Synopsis

• Usage:
permute(M,s)
• Inputs:
• M, , an $n$-dimensional matrix.
• s, a list, a permutation of the set $\{0,1,\ldots,n-1\}$.
• Outputs:
• , with the same entries as the input, but with the dimensions re-ordered according to the specified permutation.

Description

According to the definition given on page 449 of the book Discriminants, Resultants, and Multidimensional Determinants, the output of this method is $s'(M)$, where $s'$ is the inverse permutation of $s$.

 i1 : M = genericMultidimensionalMatrix {4,3,2} o1 = {{{a , a }, {a , a }, {a , a }}, {{a , 0,0,0 0,0,1 0,1,0 0,1,1 0,2,0 0,2,1 1,0,0 ------------------------------------------------------------------------ a }, {a , a }, {a , a }}, {{a , a }, 1,0,1 1,1,0 1,1,1 1,2,0 1,2,1 2,0,0 2,0,1 ------------------------------------------------------------------------ {a , a }, {a , a }}, {{a , a }, {a , 2,1,0 2,1,1 2,2,0 2,2,1 3,0,0 3,0,1 3,1,0 ------------------------------------------------------------------------ a }, {a , a }}} 3,1,1 3,2,0 3,2,1 o1 : 3-dimensional matrix of shape 4 x 3 x 2 over ZZ[a ..a ] 0,0,0 3,2,1 i2 : permute(M,{1,0,2}) o2 = {{{a , a }, {a , a }, {a , a }, {a , 0,0,0 0,0,1 1,0,0 1,0,1 2,0,0 2,0,1 3,0,0 ------------------------------------------------------------------------ a }}, {{a , a }, {a , a }, {a , a }, 3,0,1 0,1,0 0,1,1 1,1,0 1,1,1 2,1,0 2,1,1 ------------------------------------------------------------------------ {a , a }}, {{a , a }, {a , a }, {a , 3,1,0 3,1,1 0,2,0 0,2,1 1,2,0 1,2,1 2,2,0 ------------------------------------------------------------------------ a }, {a , a }}} 2,2,1 3,2,0 3,2,1 o2 : 3-dimensional matrix of shape 3 x 4 x 2 over ZZ[a ..a ] 0,0,0 3,2,1 i3 : permute(M,{2,0,1}) o3 = {{{a , a , a }, {a , a , a }, {a , a , 0,0,0 0,1,0 0,2,0 1,0,0 1,1,0 1,2,0 2,0,0 2,1,0 ------------------------------------------------------------------------ a }, {a , a , a }}, {{a , a , a }, {a , 2,2,0 3,0,0 3,1,0 3,2,0 0,0,1 0,1,1 0,2,1 1,0,1 ------------------------------------------------------------------------ a , a }, {a , a , a }, {a , a , a }}} 1,1,1 1,2,1 2,0,1 2,1,1 2,2,1 3,0,1 3,1,1 3,2,1 o3 : 3-dimensional matrix of shape 2 x 4 x 3 over ZZ[a ..a ] 0,0,0 3,2,1