Revision as of 19:18, 23 September 2014 by Nathaniel
|Produces a unitary operator that permutes subsystems|
|Other toolboxes required||none|
|Related functions|| PermuteSystems|
|Function category||Permutations and symmetry of subsystems|
- P = PermutationOperator(DIM,PERM)
- P = PermutationOperator(DIM,PERM,INV_PERM)
- P = PermutationOperator(DIM,PERM,INV_PERM,SP)
- 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.
The standard swap operator
Similarly, the following code produces a sparse operator that swaps two qutrits:
Click on "expand" to the right to view the MATLAB source code for this function.
%% PERMUTATIONOPERATOR Produces a unitary operator that permutes subsystems
% This function has two required arguments:
% DIM: the dimensions of the subsystems to be permuted
% PERM: a permutation vector
% P = PermutationOperator(DIM,PERM) is a unitary operator that permutes
% the order of subsystems according to the permutation vector PERM, where
% the ith subsystem has dimension DIM(i).
% This function has three optional arguments:
% INV_PERM (default 0)
% SP (default 0)
% P = PermutationOperator(DIM,PERM,INV_PERM,SP) is the same as above, but
% it implements the inverse permutation of PERM if INV_PERM=1. The
% permutation operator returned is full if SP=0 and sparse if SP=1.
% URL: http://www.qetlab.com/PermutationOperator
% requires: iden.m, opt_args.m, PermuteSystems.m
% author: Nathaniel Johnston (email@example.com)
% package: QETLAB
% last updated: November 28, 2012
function P = PermutationOperator(dim,perm,varargin)
% set optional argument defaults: inv_perm=0, sp=0
% allow the user to enter a single number for dim
% swap the rows of Id appropriately
P = PermuteSystems(iden(prod(dim),sp),perm,dim,1,inv_perm);