I am looking for an easy way to generate a simple linear map in Octave. The matrix I need, call it sigma(n), is defined by the following property: for all matrices A and B (both of dimension n) we have the equation:
sigma(n) * kron(A,B) = kron(B,A) * sigma(n)
For example,
sigma(2) = [1,0,0,0; 0,0,1,0; 0,1,0,0; 0,0,0,1].
Is there a simple function for sigma(n)?
For my purposes n will be fairly small, less than 50, so efficiency is not a concern.
EDIT: now with the correct defining equation
I realise it’s bad form to answer one’s own question, but with a small amount of head scratching I managed to generate the matrix explicitly:
If anyone has a neater way to do this, I’m still interested.