Difference between revisions of "PermutationOperator"

From QETLAB
Jump to navigation Jump to search
m
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
 
|name=PermutationOperator
 
|name=PermutationOperator
 
|desc=Produces a [[unitary operator]] that permutes subsystems
 
|desc=Produces a [[unitary operator]] that permutes subsystems
|req=[[opt_args]]<br />[[PermuteSystems]]
+
|rel=[[PermuteSystems]]<br />[[Swap]]<br />[[SwapOperator]]<br />[[SymmetricProjection]]
|rel=[[Swap]]<br />[[SwapOperator]]<br />[[SymmetricProjection]]
+
|cat=[[List of functions#Permutations_and_symmetry_of_subsystems|Permutations and symmetry of subsystems]]
|upd=November 14, 2012
+
|upd=November 28, 2012
|v=1.00|}}
+
|v=0.50}}
 
<tt>'''PermutationOperator'''</tt> is a [[List of functions|function]] that returns a [[unitary operator]] that permutes two or more subsystems. The unitary can be chosen to be full or sparse.
 
<tt>'''PermutationOperator'''</tt> is a [[List of functions|function]] that returns a [[unitary operator]] that permutes two or more subsystems. The unitary can be chosen to be full or sparse.
  
Line 26: Line 26:
 
The following code produces the operator that [[swap operator|swaps]] two [[qubit]]s (note that for simple uses like this one, it may be easier to just use the <tt>[[SwapOperator]]</tt> function):
 
The following code produces the operator that [[swap operator|swaps]] two [[qubit]]s (note that for simple uses like this one, it may be easier to just use the <tt>[[SwapOperator]]</tt> function):
  
<pre>
+
<syntaxhighlight>
 
>> PermutationOperator(2,[2,1])
 
>> PermutationOperator(2,[2,1])
  
Line 35: Line 35:
 
     0    1    0    0
 
     0    1    0    0
 
     0    0    0    1
 
     0    0    0    1
</pre>
+
</syntaxhighlight>
  
 
Similarly, the following code produces a sparse operator that swaps two [[qutrit]]s:
 
Similarly, the following code produces a sparse operator that swaps two [[qutrit]]s:
  
<pre>
+
<syntaxhighlight>
 
>> PermutationOperator(3,[2,1],0,1)
 
>> PermutationOperator(3,[2,1],0,1)
  
Line 53: Line 53:
 
   (6,8)        1
 
   (6,8)        1
 
   (9,9)        1
 
   (9,9)        1
</pre>
+
</syntaxhighlight>
 +
 
 +
{{SourceCode|name=PermutationOperator}}

Latest revision as of 19:18, 23 September 2014

PermutationOperator
Produces a unitary operator that permutes subsystems

Other toolboxes required none
Related functions PermuteSystems
Swap
SwapOperator
SymmetricProjection
Function category Permutations and symmetry of subsystems

PermutationOperator is a function that returns a unitary operator that permutes two or more subsystems. The unitary can be chosen to be full or sparse.

Syntax

  • P = PermutationOperator(DIM,PERM)
  • P = PermutationOperator(DIM,PERM,INV_PERM)
  • P = PermutationOperator(DIM,PERM,INV_PERM,SP)

Argument descriptions

  • DIM: A specification of the dimensions of the subsystems that P will act on. DIM can be provided in one of two ways:
    • If DIM is a scalar, then all subsystems are assumed to have dimension DIM.
    • If the subsystems have unequal dimensions, DIM should be a vector containing their dimensions.
  • PERM: a permutation vector (i.e., a permutation of the vector 1:n)
  • INV_PERM (optional, default 0): If equal to 0, this argument has no effect. If equal to 1, the permutation operator permutes subsystems according to the inverse of PERM rather than PERM itself.
  • SP (optional, default 0): If set equal to 1, the permutation operator is sparse. If equal to 0, the permutation operator is full.

Examples

The standard swap operator

The following code produces the operator that swaps two qubits (note that for simple uses like this one, it may be easier to just use the SwapOperator function):

>> PermutationOperator(2,[2,1])

ans =

     1     0     0     0
     0     0     1     0
     0     1     0     0
     0     0     0     1

Similarly, the following code produces a sparse operator that swaps two qutrits:

>> PermutationOperator(3,[2,1],0,1)

ans =

   (1,1)        1
   (4,2)        1
   (7,3)        1
   (2,4)        1
   (5,5)        1
   (8,6)        1
   (3,7)        1
   (6,8)        1
   (9,9)        1

Source code

Click here to view this function's source code on github.