function r = top_k_subgrad(x,s)
% g(X) = ||X||_{top-k}
% return the subgradient of g(X)

[m,n] = size(x);
r = zeros(m,n);
x = x(:);
[~,ind] = sort(abs(x),'descend');
ind = ind(1:s);
r(ind) = sign(x(ind));
