RandomSuperoperator

From QETLAB
Jump to: navigation, search
RandomSuperoperator
Generates a random superoperator (completely positive map)

Other toolboxes required none
Related functions RandomDensityMatrix
RandomPOVM
RandomStateVector
RandomUnitary
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).

Syntax

  • 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)

Argument descriptions

  • 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)).

Examples

Random qubit channel

The following code generates a random qubit channel and verifies that it is indeed a qubit channel:

>> Phi = RandomSuperoperator(2);
>> ApplyMap(eye(2),DualMap(Phi)) % the dual map is unital if and only if Phi is trace-preserving
 
ans =
 
   1.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

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]

Notes

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.

Source code

Click on "expand" to the right to view the MATLAB source code for this function.

  1. %%  RANDOMSUPEROPERATOR    Generates a random superoperator
  2. %   This function has one required argument:
  3. %     DIM: either a scalar or a 1-by-2 vector specifying the input and
  4. %          output dimensions of the superoperator, in that order
  5. %
  6. %   PHI = RandomSuperoperator(DIM) generates the Choi matrix of a random
  7. %   quantum channel (i.e., a completely positive, trace-preserving linear
  8. %   map) acting on DIM-by-DIM matrices.
  9. %
  10. %   This function has four optional arguments:
  11. %     TP (default 1)
  12. %     UN (default 0)
  13. %     RE (default 0)
  14. %     KR (default prod(DIM))
  15. %
  16. %   PHI = RandomSuperoperator(DIM,TP,UN,RE,KR) generates the Choi matrix of
  17. %   a random superoperator that is trace-preserving if TP=1, is unital if
  18. %   UN=1, has all real entries if RE=1, and has KR or fewer Kraus operators
  19. %   (it will have exactly KR Kraus operators with probability 1).
  20. %
  21. %   URL: http://www.qetlab.com/RandomSuperoperator
  22.  
  23. %   requires: iden.m, MaxEntangled.m, OperatorSinkhorn.m, opt_args.m,
  24. %             PartialTrace.m, PermuteSystems.m, RandomDensityMatrix.m,
  25. %             RandomStateVector.m, RandomUnitary.m, SchmidtDecomposition.m,
  26. %             Swap.m
  27. %             
  28. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
  29. %   package: QETLAB
  30. %   last updated: September 30, 2014
  31.  
  32. function Phi = RandomSuperoperator(dim,varargin)
  33.  
  34. % allow the user to enter a single number for dim
  35. if(length(dim) == 1)
  36.     dim = [dim,dim];
  37. end
  38. pd = prod(dim);
  39.  
  40. % set optional argument defaults: tp=1, un=0, re=0, kr=prod(dim)
  41. [tp,un,re,kr] = opt_args({ 1, 0, 0, pd },varargin{:});
  42.  
  43. if(tp == 1 && un == 1 && dim(1) ~= dim(2))
  44.     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.');
  45. end
  46.  
  47. % There is a probability 0 chance that the operator Sinkhorn iteration will
  48. % get cranky. Thus we repeatedly try until we *don't* get an error
  49. % (honestly, I'm being slightly overly cautious).
  50. sing_err = 1;
  51. while sing_err
  52.     sing_err = 0;
  53.     try
  54.         % Generate the Choi matrix of a superoperator that is not
  55.         % necessarily trace-preserving or unital. We will enforce those
  56.         % conditions in a moment.
  57.         Phi = RandomDensityMatrix(pd,re,kr,'haar');
  58.  
  59.         % Now set the appropriate partial traces to the identity.
  60.         if(tp == 1 && un == 0)
  61.             PT = kron(sqrtm(inv(PartialTrace(Phi,2,dim))),eye(dim(2)));
  62.             Phi = PT*Phi*PT;
  63.         elseif(tp == 0 && un == 1)
  64.             PT = kron(eye(dim(1)),sqrtm(inv(PartialTrace(Phi,1,dim))));
  65.             Phi = PT*Phi*PT;
  66.         elseif(tp == 1 && un == 1)
  67.             Phi = OperatorSinkhorn(Phi,dim)*dim(1);
  68.         end
  69.     catch err
  70.         % Operator Sinkhorn error? Try, try again!
  71.         if(strcmpi(err.identifier,'OperatorSinkhorn:LowRank'))
  72.             sing_err = 1;
  73.         else
  74.             rethrow(err);
  75.         end
  76.     end
  77. end