%% function [cvx_optval,x] = RobMag(rho,T)
% computes the robustness of magic of the state rho
% requires as second argument the matrix T whose columns are pure stabilizer states
%
% based on Seddon et al., arXiv:2002.06181

function [cvx_optval,x] = RobMag(rho,T)

k = size(T,2);

cvx_begin quiet

variable x(k)

X = diag(x);
rho == T*X*T'
minimize norm(x,1)

cvx_end

end