# Tag Info

If you don't know what the numerical values of $i$ and $j$, then it will be hard to implement the index swap. However, it is easy to programmatically implement the index list as an argument for TensorTranspose: Permute[Range[1, 10], Cycles[{{2, 5}}]] (* => {1, 5, 3, 4, 2, 6, 7, 8, 9, 10} *) Thus, you could do something like twoWayTranspose[T_, {i_, ...
To convert a list of linear expressions to a matrix containing the coefficients the following is easier to write than CoefficientArrays, but seems to be a little slower: D[identity, {basis}] \left( \begin{array}{cccccc} 1 & 0 & 1 & 0 & 0 & -1 \\ 0 & 1 & 1 & 0 & 0 & 0 \\ -1 & 0 & 0 & 1 & -1 ...