Operational applications of the diamond norm and related measures in quantifying the non-physicality of quantum maps

Code accompanying the manuscript Quantum 5, 522 (2021) (arXiv:2102.07773).

The MATLAB code below shows an implementation of the SDPs for the various measures described in the manuscript. It requires CVX to run the optimisation problems and uses the helper function PartialTrace from QETLAB. The programs all have the same structure: as an argument, they take the Choi matrix J of a given Hermiticity-preserving map and optionally a tuple of input/output dimensions [d_A, d_B] (assumed to be equal if not provided). In addition to the optimal value, they return an optimal decomposition of J (depending on the definition of the given measure) and an optimal dual witness W which can be used to certify the optimal value (as per the dual forms of the programs given in the manuscript).

Download MATLAB files:


Diamond norm $\|\cdot\|_{\Diamond}$

function [cvx_optval,X,Y,W] = Diamond(J,dim)
    
J = (J+J')/2; % make sure that J is Hermitian, avoid numerical issues

if nargin<2
    d = max(size(J));
    dim = [1,1]*sqrt(d);
else
    d = dim(1)*dim(2);
end
 
cvx_begin sdp quiet

   variable X(d,d) hermitian semidefinite
   variable Y(d,d) hermitian semidefinite
   variable mu nonnegative
   dual variable W
   
   PartialTrace(X+Y,2,dim) <= mu*eye(dim(1));
   W: X-Y == J;
   
   minimize mu
   
cvx_end
   
end

CPTNI base norm $\|\cdot\|_{\blacklozenge}$

function [cvx_optval,X,Y,W] = NormCPTNI(J,dim)
    
J = (J+J')/2; % make sure that J is Hermitian, avoid numerical issues

if nargin<2
    d = max(size(J));
    dim = [1,1]*sqrt(d);
else
    d = dim(1)*dim(2);
end
 
cvx_begin sdp quiet

   variable X(d,d) hermitian semidefinite
   variable Y(d,d) hermitian semidefinite
   variable mu1 nonnegative
   variable mu2 nonnegative
   dual variable W
   
   PartialTrace(X,2,dim) <= mu1*eye(dim(1));
   PartialTrace(Y,2,dim) <= mu2*eye(dim(1));
   W: X-Y == J;
   
   minimize mu1+mu2
   
cvx_end
   
end

Robustness $R$ (variant 1)

function [cvx_optval,X,W,Y] = RobCPTNI(J,dim)
    
J = (J+J')/2; % make sure that J is Hermitian, avoid numerical issues

if nargin<2
    d = max(size(J));
    dim = [1,1]*sqrt(d);
else
    d = dim(1)*dim(2);
end
 
cvx_begin sdp quiet

   variable X(d,d) hermitian semidefinite
   variable lam nonnegative
   dual variable Z
   dual variable Y
   
   PartialTrace(X,2,dim) <= lam*eye(dim(1));
   Y: PartialTrace(J+X,2,dim) <= (1+lam)*eye(dim(1));
   Z: J + X >=0
   
   minimize lam
   
cvx_end

W = kron(Y,eye(dim(2)))-Z; % notation from the paper
   
end

Robustness $R'$ (variant 2)

function [cvx_optval,X,W] = RobCPTNI2(J,dim)
    
J = (J+J')/2; % make sure that J is Hermitian, avoid numerical issues

if nargin<2
    d = max(size(J));
    dim = [1,1]*sqrt(d);
else
    d = dim(1)*dim(2);
end
 
cvx_begin sdp quiet

   variable X(d,d) hermitian semidefinite
   variable lam nonnegative
   dual variable W
   
   PartialTrace(X,2,dim) <= (1+lam)*eye(dim(1));
   W : X >= J
   
   minimize lam
   
cvx_end
   
end