Realignment

Realignment is a function that computes the realignment of a bipartite operator.

Syntax

 * RX = Realignment(X)
 * RX = Realignment(X,DIM)

Argument descriptions

 * X: A bipartite operator to have its realignment computed.
 * DIM (optional, by default has both subsystems of equal dimension): A specification of the dimensions of the subsystems that X lives on. DIM can be provided in one of three ways:
 * If DIM is a scalar, it is assumed that the first subsystem has dimension DIM</tt> and the second subsystem has dimension length(X)/DIM</tt>.
 * If $X \in M_{n_1} \otimes M_{n_2}$ then DIM</tt> should be a row vector containing the dimensions (i.e., DIM = [n_1, n_2]</tt>).
 * If the subsystems aren't square (i.e., $X \in M_{m_1, n_1} \otimes M_{m_2, n_2}$) 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_2; n_1, n_2]</tt>.

A two-qubit example
When viewed as a map on block matrices, the realignment map takes each block of the original matrix and makes its vectorization the rows of the realignment matrix. This is illustrated by the following small example:

A non-square example
The realignment map sends $|i\rangle\langle j| \otimes |k\rangle\langle \ell|$ to $|i\rangle\langle k| \otimes |j\rangle\langle \ell|$. Thus it changes the dimensions of matrices if the subsystems aren't square and of the same size. The following code computes the realignment of an operator $X \in M_{5,2} \otimes M_{3,7}$: