|Generates a random superoperator (completely positive map)|
|Other toolboxes required||none|
|Related functions|| RandomDensityMatrix|
|Function category||Random things|
RandomSuperoperator is a function that generates a random completely positive map satisfying some user-specified properties (such as being trace-preserving, being unital, and/or having a specified number of Kraus operators).
- PHI = RandomSuperoperator(DIM)
- PHI = RandomSuperoperator(DIM,TP)
- PHI = RandomSuperoperator(DIM,TP,UN)
- PHI = RandomSuperoperator(DIM,TP,UN,RE)
- PHI = RandomSuperoperator(DIM,TP,UN,RE,KR)
- DIM: Either a scalar, indicating that PHI should act on DIM-by-DIM matrices, or a 1-by-2 vector, indicating that PHI should take DIM(1)-by-DIM(1) matrices as input and return DIM(2)-by-DIM(2) matrices as output.
- TP (optional, default 1): A flag (either 1 or 0) indicating that PHI should or should not be trace-preserving.
- UN (optional, default 0): A flag (either 1 or 0) indicating that PHI should or should not be unital (i.e., satisfy $\Phi(I) = I$).
- RE (optional, default 0): A flag (either 1 or 0) indicating that the Choi matrix of PHI (equivalently, its Kraus operators) should only have real entries (RE = 1) or that it is allowed to have complex entries (RE = 0).
- KR (optional, default prod(DIM)): The maximal number of Kraus operators of the superoperator to be produced. With probability 1, it will have exactly KR Kraus operators (if KR ≤ prod(DIM)).
Random qubit channel
The following code generates a random qubit channel and verifies that it is indeed a qubit channel:
Random unital channel with specified number of Kraus operators
You can request completely positive maps with any combination of the optional arguments as constraints. For example, the following code requests a random unital quantum channel that sends 3-by-3 matrices to 4-by-4 matrices and has 5 Kraus operators. Note that a warning is produced because, strictly speaking, no such map exists (it's impossible for a map to be both trace-preserving and unital unless the input and output dimensions are the same). Instead, the map is that is produced is trace-preserving and sends the identity matrix to a scalar multiple of the identity matrix.
>> Phi = RandomSuperoperator([3,4],1,1,0,5); Warning: There does not exist a unital, trace-preserving map in the case when the input and output dimensions are unequal. The identity matrix will map to a *multiple* of the identity matrix. > In RandomSuperoperator at 45 >> ApplyMap(eye(3),Phi) % verify that Phi is (up to scaling) unital ans = 0.7500 + 0.0000i -0.0000 - 0.0000i -0.0000 - 0.0000i -0.0000 - 0.0000i -0.0000 + 0.0000i 0.7500 + 0.0000i 0.0000 + 0.0000i -0.0000 - 0.0000i -0.0000 + 0.0000i 0.0000 - 0.0000i 0.7500 + 0.0000i -0.0000 + 0.0000i -0.0000 + 0.0000i -0.0000 + 0.0000i -0.0000 - 0.0000i 0.7500 + 0.0000i >> ApplyMap(eye(4),DualMap(Phi,[3,4])) % verify that Phi is trace-preserving ans = 1.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 - 0.0000i 1.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 - 0.0000i 0.0000 - 0.0000i 1.0000 - 0.0000i >> IsCP(Phi) % verify that Phi is completely positive ans = 1 >> KrausOperators(Phi,[3,4]) % verify that Phi has 5 Kraus operators ans = [4x3 double] [4x3 double] [4x3 double] [4x3 double] [4x3 double]
The superoperator is not generated with regard to any well-known or well-studied distribution, but it can output any superoperator satisfying the specified constraints (unital, trace-preserving, number of Kraus operators), and it derives from uniform spherical measure in a fairly straightforward way.
Click on "expand" to the right to view the MATLAB source code for this function.
%% RANDOMSUPEROPERATOR Generates a random superoperator
% This function has one required argument:
% DIM: either a scalar or a 1-by-2 vector specifying the input and
% output dimensions of the superoperator, in that order
% PHI = RandomSuperoperator(DIM) generates the Choi matrix of a random
% quantum channel (i.e., a completely positive, trace-preserving linear
% map) acting on DIM-by-DIM matrices.
% This function has four optional arguments:
% TP (default 1)
% UN (default 0)
% RE (default 0)
% KR (default prod(DIM))
% PHI = RandomSuperoperator(DIM,TP,UN,RE,KR) generates the Choi matrix of
% a random superoperator that is trace-preserving if TP=1, is unital if
% UN=1, has all real entries if RE=1, and has KR or fewer Kraus operators
% (it will have exactly KR Kraus operators with probability 1).
% URL: http://www.qetlab.com/RandomSuperoperator
% requires: iden.m, MaxEntangled.m, OperatorSinkhorn.m, opt_args.m,
% PartialTrace.m, PermuteSystems.m, RandomDensityMatrix.m,
% RandomStateVector.m, RandomUnitary.m, SchmidtDecomposition.m,
% author: Nathaniel Johnston (firstname.lastname@example.org)
% package: QETLAB
% last updated: September 30, 2014
function Phi = RandomSuperoperator(dim,varargin)
% allow the user to enter a single number for dim
if(length(dim) == 1)
dim = [dim,dim];
pd = prod(dim);
% set optional argument defaults: tp=1, un=0, re=0, kr=prod(dim)
if(tp == 1 && un == 1 && dim(1) ~= dim(2))
warning('RandomSuperoperator:InvalidDim','There does not exist a unital, trace-preserving map in the case when the input and output dimensions are unequal. The identity matrix will map to a *multiple* of the identity matrix.');
% There is a probability 0 chance that the operator Sinkhorn iteration will
% get cranky. Thus we repeatedly try until we *don't* get an error
% (honestly, I'm being slightly overly cautious).
sing_err = 1;
sing_err = 0;
% Generate the Choi matrix of a superoperator that is not
% necessarily trace-preserving or unital. We will enforce those
% conditions in a moment.
Phi = RandomDensityMatrix(pd,re,kr,'haar');
% Now set the appropriate partial traces to the identity.
if(tp == 1 && un == 0)
PT = kron(sqrtm(inv(PartialTrace(Phi,2,dim))),eye(dim(2)));
Phi = PT*Phi*PT;
elseif(tp == 0 && un == 1)
PT = kron(eye(dim(1)),sqrtm(inv(PartialTrace(Phi,1,dim))));
Phi = PT*Phi*PT;
elseif(tp == 1 && un == 1)
Phi = OperatorSinkhorn(Phi,dim)*dim(1);
% Operator Sinkhorn error? Try, try again!
sing_err = 1;