Difference between revisions of "SwapOperator"

From QETLAB
Jump to navigation Jump to search
m
 
Line 6: Line 6:
 
|upd=November 12, 2014
 
|upd=November 12, 2014
 
|v=0.60}}
 
|v=0.60}}
<tt>'''SwapOperator'''</tt> is a [[List of functions|function]] that returns a unitary operator that swaps two subsystems (there may be more than two subsystems overall &ndash; the extra subsystems are left alone). The unitary can be chosen to be full or sparse.
+
<tt>'''SwapOperator'''</tt> is a [[List of functions|function]] that returns a unitary operator that swaps two subsystems. The unitary can be chosen to be full or sparse.
  
 
==Syntax==
 
==Syntax==
 
* <tt>S = SwapOperator(DIM)</tt>
 
* <tt>S = SwapOperator(DIM)</tt>
* <tt>S = SwapOperator(DIM,SYS)</tt>
+
* <tt>S = SwapOperator(DIM,SP)</tt>
* <tt>S = SwapOperator(DIM,SYS,SP)</tt>
 
  
 
==Argument descriptions==
 
==Argument descriptions==
 
* <tt>DIM</tt>: A specification of the dimensions of the subsystems that <tt>S</tt> will act on. <tt>DIM</tt> can be provided in one of two ways:
 
* <tt>DIM</tt>: A specification of the dimensions of the subsystems that <tt>S</tt> will act on. <tt>DIM</tt> can be provided in one of two ways:
** If <tt>DIM</tt> is a scalar, then all subsystems are assumed to have dimension <tt>DIM</tt>.
+
** If <tt>DIM</tt> is a scalar, then both subsystems are assumed to have dimension <tt>DIM</tt>.
** If the subsystems have unequal dimensions, <tt>DIM</tt> should be a vector containing their dimensions.
+
** If the subsystems have unequal dimensions, <tt>DIM</tt> should be a 1-by-2 vector containing their dimensions.
* <tt>SYS</tt> (optional, default <tt>[1,2]</tt>): A 1-by-2 vector containing the indices of the subsystems to be swapped.
 
 
* <tt>SP</tt> (optional, default 0): If set equal to 1, the swap operator is sparse. If equal to 0, the swap operator is full.
 
* <tt>SP</tt> (optional, default 0): If set equal to 1, the swap operator is sparse. If equal to 0, the swap operator is full.
  
 
==Examples==
 
==Examples==
 
===The standard swap operator===
 
===The standard swap operator===
 
 
The following code produces the operator that swaps two qubits:
 
The following code produces the operator that swaps two qubits:
  

Latest revision as of 17:56, 12 November 2014

SwapOperator
Produces a unitary operator that swaps two subsystems

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

SwapOperator is a function that returns a unitary operator that swaps two subsystems. The unitary can be chosen to be full or sparse.

Syntax

  • S = SwapOperator(DIM)
  • S = SwapOperator(DIM,SP)

Argument descriptions

  • DIM: A specification of the dimensions of the subsystems that S will act on. DIM can be provided in one of two ways:
    • If DIM is a scalar, then both subsystems are assumed to have dimension DIM.
    • If the subsystems have unequal dimensions, DIM should be a 1-by-2 vector containing their dimensions.
  • SP (optional, default 0): If set equal to 1, the swap operator is sparse. If equal to 0, the swap operator is full.

Examples

The standard swap operator

The following code produces the operator that swaps two qubits:

>> SwapOperator(2)

ans =

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

Source code

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