RandomSuperoperator

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</tt>-by-DIM</tt> matrices, or a 1-by-2 vector, indicating that PHI</tt> should take DIM(1)</tt>-by-DIM(1)</tt> matrices as input and return DIM(2)</tt>-by-DIM(2)</tt> matrices as output.
 * TP</tt> (optional, default 1): A flag (either 1 or 0) indicating that PHI</tt> should or should not be trace-preserving.
 * UN</tt> (optional, default 0): A flag (either 1 or 0) indicating that PHI</tt> should or should not be unital (i.e., satisfy $\Phi(I) = I$).
 * RE</tt> (optional, default 0): A flag (either 1 or 0) indicating that the Choi matrix of PHI</tt> (equivalently, its Kraus operators) should only have real entries (RE = 1</tt>) or that it is allowed to have complex entries (RE = 0</tt>).
 * KR</tt> (optional, default <tt>prod(DIM)</tt>): The maximal number of Kraus operators of the superoperator to be produced. With probability 1, it will have exactly <tt>KR</tt> Kraus operators (if <tt>KR &le; prod(DIM)</tt>).

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.