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