PermuteSystems

PermuteSystems is a function that allows the user to permute the order of the subsystems underlying a quantum state or operator that is defined on the tensor product of 2 or more subsystems. It works with full and sparse numeric matrices as well as symbolic matrices.

Syntax

 * PX = PermuteSystems(X,PERM)
 * PX = PermuteSystems(X,PERM,DIM)
 * PX = PermuteSystems(X,PERM,DIM,ROW_ONLY)
 * PX = PermuteSystems(X,PERM,DIM,ROW_ONLY,INV_PERM)

Argument Descriptions

 * X: a vector (e.g., a pure quantum state) or a matrix to have its subsystems permuted
 * PERM: a permutation vector (i.e., a permutation of the vector 1:n)
 * DIM</tt> (optional, by default has all subsystems of equal dimension): A specification of the dimensions of the subsystems that X</tt> lives on. DIM</tt> can be provided in one of two ways:
 * If $X \in M_{n_1} \otimes \cdots \otimes M_{n_p}$ then DIM</tt> should be a row vector containing the dimensions (i.e., DIM = [n_1, ..., n_p]</tt>).
 * If the subsystems aren't square (i.e., $X \in M_{m_1, n_1} \otimes \cdots \otimes M_{m_p, n_p}$) then DIM</tt> should be a matrix with two rows. The first row of DIM</tt> should contain the row dimensions of the subsystems (i.e., the mi's) and its second row should contain the column dimensions (i.e., the ni's). In other words, you should set DIM = [m_1, ..., m_p; n_1, ..., n_p]</tt>.
 * ROW_ONLY</tt> (optional, default 0</tt>): If set equal to 1</tt>, only the rows of X</tt> are permuted (this is equivalent to multiplying X</tt> on the left by PermutationOperator(DIM,PERM)</tt>). If equal to 0</tt>, both the rows and columns of X</tt> are permuted (this is equivalent to multiplying <tt>X</tt> on both the left and right by the permutation operator).
 * <tt>INV_PERM</tt> (optional, default <tt>0</tt>): If equal to 0, this argument has no effect. If equal to 1, the subsystems are permuted according to the inverse of <tt>PERM</tt> rather than <tt>PERM</tt> itself.

All subsystems of equal dimension
In cases when all subsystems have the same dimension, most arguments can be omitted. Let's start with a matrix $X \in M_2 \otimes M_2$:

If we want to permute the two subsystems, we can call <tt>PermuteSystems</tt> with the permutation vector <tt>PERM = [2,1]</tt> (though if your needs are as simple as this, you may be better off using the <tt>Swap</tt> function):

Similarly, the following code acts on a matrix $X \in M_A \otimes M_B \otimes M_C$ (where each subsystem has dimension 2) and outputs a matrix representation in the standard basis of $M_B \otimes M_C \otimes M_A$: