J. Phys. A: Math. Theor. 51, 045303 (2018)
Download the Matlab file:
Section 5 of the manuscript introduces quantum resource quantifiers based on the so-called k-support norm, first defined in A. Argyriou, R. Foygel, and N. Srebro, Sparse Prediction with the k-Support Norm (arXiv:1204.5043). The computation of this quantity follows from the formula obtained by Argyriou et al. and can be easily implemented in Matlab as
function [ksupp] = ksupport(psi, k)
% (k-support norm)^2 of the vector psi
% Arguments: vector psi, k (1<=k<=d).
w = sort(abs(psi),'descend');
Ar = sum(w(k+1:length(psi))); % A_{r-1} for r=0
for r=0:k-1
Ar = Ar + w(k-r); %A_r
if r<k-1 && Ar < (r+1)*w(k-r-1) && Ar >= (r+1)*w(k-r)
break;
end
end
ksupp = sum(w(1:k-r-1).^2) + (Ar^2)/(r+1);
end
or in Mathematica as
ksupport[psi_, k_] :=
Module[{w = Sort[Abs@psi, Greater], r, d = Length@psi},
r = Catch[
If[w[[k - # - 1]]*(# + 1) >
Total@w[[k - # ;; d]] >= (# + 1)*w[[k - #]], Throw[#],
Unevaluated[Sequence[]]] & /@ Range[0, k - 2]; k - 1];
Return[
Total[w[[1 ;; k - r - 1]]^2] + (Total@w[[k - r ;; d]])^2/(r +
1)];
];
Note that the above returns the squared k-support norm, and we do not take the square root since the quantity of interest in the manuscript corresponds to (k-support norm)2 - 1 anyway.
Download the Matlab file:
A quantity derived from the k-support norm is the k-support norm of entanglement, first used in N. Johnston and D. W. Kribs, Duality of entanglement norms (arXiv:1304.2328). This is simply the k-support norm of the appropriately padded Schmidt vector of the state, and it can be implemented as
function ent = kentanglement(psi,k,varargin)
% kentanglement(psi,k,dim) computes the (k-support norm of entanglement)^2 of the vector psi
% Arguments: vector psi, k (1<=k<=d), (optional) dimensions of the two systems
if nargin > 2
dim = varargin{1};
else
dim = sqrt(length(psi));
end
if isscalar(dim)
schm = svd(reshape(psi,dim,dim).');
else
schm = svd(reshape(psi,dim(2),dim(1)).');
end
vec = [schm; zeros(min(dim)-length(schm),1)];
ent = ksupport(schm,k);
end
or in Mathematica as
kentanglement[psi_, k_, dims_: Automatic] :=
Module[{len = Length@psi, idims},
idims = dims /. Automatic -> Sqrt@len;
If[Length@idims == 0,
Return@
ksupport[
PadRight[SingularValueList@ArrayReshape[psi, {idims, idims}],
idims], k],
Return@
ksupport[
PadRight[SingularValueList@ArrayReshape[psi, idims],
Min@idims], k];
];(*If*)
];
Note that once again we return the squared norm. The dimensions of the subsystems can be passed to the function as the optional third argument, otherwise they are assumed to be equal.