# Realignment

 Other toolboxes required Realignment Computes the realignment of a bipartite operator none PartialTransposePermuteSystemsSwap Superoperators

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 and the second subsystem has dimension length(X)/DIM.
• If $X \in M_{n_1} \otimes M_{n_2}$ then DIM should be a row vector containing the dimensions (i.e., DIM = [n_1, n_2]).
• If the subsystems aren't square (i.e., $X \in M_{m_1, n_1} \otimes M_{m_2, n_2}$) then DIM should be a matrix with two rows. The first row of DIM 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].

## Examples

### 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:

>> X = reshape(1:16,4,4)'

X =

1     2     3     4
5     6     7     8
9    10    11    12
13    14    15    16

>> Realignment(X)

ans =

1     2     5     6
3     4     7     8
9    10    13    14
11    12    15    16

### 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}$:

>> X = reshape(1:210,14,15)'

X =

1     2     3     4     5     6     7     8     9    10    11    12    13    14
15    16    17    18    19    20    21    22    23    24    25    26    27    28
29    30    31    32    33    34    35    36    37    38    39    40    41    42
43    44    45    46    47    48    49    50    51    52    53    54    55    56
57    58    59    60    61    62    63    64    65    66    67    68    69    70
71    72    73    74    75    76    77    78    79    80    81    82    83    84
85    86    87    88    89    90    91    92    93    94    95    96    97    98
99   100   101   102   103   104   105   106   107   108   109   110   111   112
113   114   115   116   117   118   119   120   121   122   123   124   125   126
127   128   129   130   131   132   133   134   135   136   137   138   139   140
141   142   143   144   145   146   147   148   149   150   151   152   153   154
155   156   157   158   159   160   161   162   163   164   165   166   167   168
169   170   171   172   173   174   175   176   177   178   179   180   181   182
183   184   185   186   187   188   189   190   191   192   193   194   195   196
197   198   199   200   201   202   203   204   205   206   207   208   209   210

>> Realignment(X,[5,3;2,7])

ans =

1     2     3     4     5     6     7    15    16    17    18    19    20    21    29    30    31    32    33    34    35
8     9    10    11    12    13    14    22    23    24    25    26    27    28    36    37    38    39    40    41    42
43    44    45    46    47    48    49    57    58    59    60    61    62    63    71    72    73    74    75    76    77
50    51    52    53    54    55    56    64    65    66    67    68    69    70    78    79    80    81    82    83    84
85    86    87    88    89    90    91    99   100   101   102   103   104   105   113   114   115   116   117   118   119
92    93    94    95    96    97    98   106   107   108   109   110   111   112   120   121   122   123   124   125   126
127   128   129   130   131   132   133   141   142   143   144   145   146   147   155   156   157   158   159   160   161
134   135   136   137   138   139   140   148   149   150   151   152   153   154   162   163   164   165   166   167   168
169   170   171   172   173   174   175   183   184   185   186   187   188   189   197   198   199   200   201   202   203
176   177   178   179   180   181   182   190   191   192   193   194   195   196   204   205   206   207   208   209   210