# RandomSuperoperator

 Other toolboxes required RandomSuperoperator Generates a random superoperator (completely positive map) none RandomDensityMatrixRandomPOVMRandomStateVectorRandomUnitary 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]```