# IsCP

 Other toolboxes required IsCP Determines whether or not a superoperator is completely positive none IsHermPreserving Superoperators

IsCP is a function that determines whether or not a given superoperator is completely positive.

## Syntax

• CP = IsCP(PHI)
• CP = IsCP(PHI,TOL)

## Argument descriptions

• PHI: A superoperator. Should be provided as either a Choi matrix, or as a cell with either 1 or 2 columns (see the tutorial page for more details about specifying superoperators within QETLAB).
• TOL (optional, default eps^(3/4)): The numerical tolerance used when determining complete positivity.

## Examples

The following code verifies that the map $\Phi$ defined by $\Phi(X) = X - UXU^*$ is not completely positive, where $U = \frac{1}{\sqrt{2}}\begin{bmatrix}1 & 1 \\ -1 & 1\end{bmatrix}$.

>> U = [1 1;-1 1]/sqrt(2);
>> Phi = {eye(2),eye(2); U,-U};
>> IsCP(Phi)

ans =

0

## Source code

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

1. %%  ISCP    Determines whether or not a superoperator is completely positive
2. %   This function has one required argument:
3. %     PHI: a superoperator
4. %
5. %   CP = IsCP(PHI) is either 1 or 0, indicating that PHI is or is not
6. %   completely positive (within reasonable numerical error).
7. %
8. %   This function has one optional input argument:
9. %     TOL (default eps^(3/4))
10. %
11. %   CP = IsCP(PHI,TOL) determines whether or not PHI is completely positive
12. %   within the numerical tolerance specified by TOL.
13. %
14. %   URL: http://www.qetlab.com/IsCP
15. 
16. %   requires: ApplyMap.m, ChoiMatrix.m, iden.m, IsHermPreserving.m,
17. %             IsPSD.m, MaxEntangled.m, opt_args.m, PermuteSystems.m,
18. %             sporth.m, superoperator_dims.m
19. %
20. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
21. %   package: QETLAB
22. %   last updated: January 4, 2013
23. 
24. function cp = IsCP(Phi,varargin)
25. 
26. if(iscell(Phi) && size(Phi,2) == 1)
27.     cp = 1;
28.     return
29. end
30. 
31. % Use Choi's theorem to determine whether or not Phi is CP.
32. C = ChoiMatrix(Phi);
33. cp = (IsHermPreserving(C,varargin{:}) && IsPSD(C,varargin{:}));