Difference between revisions of "PermutationOperator"

From QETLAB
Jump to navigation Jump to search
(Created page with "{{Function |name=PermutationOperator |desc=Produces a unitary operator that permutes subsystems |req=opt_args<br />PermuteSystems |rel=Swap<br />[[SwapOperator...")
 
m
Line 18: Line 18:
 
** 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 vector containing their dimensions.
 
* <tt>PERM</tt>: a permutation vector (i.e., a permutation of the vector <tt>1:n</tt>)
 
* <tt>PERM</tt>: a permutation vector (i.e., a permutation of the vector <tt>1:n</tt>)
* <tt>INV_PERM</tt> (optional, default <tt>0</tt>): If equal to 0, this argument has no effect. If equal to 1, the permutation operator permutes subsystems according to the inverse of <tt>PERM</tt> rather than <tt>PERM</tt> itself.
+
* <tt>INV_PERM</tt> (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 <tt>PERM</tt> rather than <tt>PERM</tt> itself.
* <tt>SP</tt> (optional, default <tt>0</tt>): If set equal to <tt>1</tt>, the permutation operator is sparse. If equal to <tt>0</tt>, the permutation operator is full.
+
* <tt>SP</tt> (optional, default 0): If set equal to 1, the permutation operator is sparse. If equal to 0, the permutation operator is full.
  
 
==Examples==
 
==Examples==

Revision as of 20:40, 14 November 2012

PermutationOperator
Produces a unitary operator that permutes subsystems

Other toolboxes required opt_args
PermuteSystems
Related functions Swap
SwapOperator

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