PermuteSystems
PermuteSystems | |
Permutes subsystems within a state or operator | |
Other toolboxes required | none |
---|---|
Related functions | PermutationOperator Swap SwapOperator |
Function category | Permutations and symmetry of subsystems |
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 (optional, by default has all subsystems of equal dimension): A specification of the dimensions of the subsystems that X lives on. DIM can be provided in one of two ways:
- If $X \in M_{n_1} \otimes \cdots \otimes M_{n_p}$ then DIM should be a row vector containing the dimensions (i.e., DIM = [n_1, ..., n_p]).
- 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 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_p; n_1, ..., n_p].
- ROW_ONLY (optional, default 0): If set equal to 1, only the rows of X are permuted (this is equivalent to multiplying X on the left by PermutationOperator(DIM,PERM)). If equal to 0, both the rows and columns of X are permuted (this is equivalent to multiplying X on both the left and right by the permutation operator).
- INV_PERM (optional, default 0): If equal to 0, this argument has no effect. If equal to 1, the subsystems are permuted according to the inverse of PERM rather than PERM itself.
Examples
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$:
>> X = [1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16]
X =
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
If we want to permute the two subsystems, we can call PermuteSystems with the permutation vector PERM = [2,1] (though if your needs are as simple as this, you may be better off using the Swap function):
>> PermuteSystems(X,[2,1])
ans =
1 3 2 4
9 11 10 12
5 7 6 8
13 15 14 16
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$:
>> X = reshape(1:64,8,8)'
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
>> PermuteSystems(X,[2,3,1])
ans =
1 5 2 6 3 7 4 8
33 37 34 38 35 39 36 40
9 13 10 14 11 15 12 16
41 45 42 46 43 47 44 48
17 21 18 22 19 23 20 24
49 53 50 54 51 55 52 56
25 29 26 30 27 31 28 32
57 61 58 62 59 63 60 64
Source code
Click here to view this function's source code on github.