function [grad] = gradRSVMPlusl1_ls(X, pos_sv,alpha_sv, beta, componentDist, C_r)
numKernel = size(X,2);
grad = zeros(numKernel, 1);

for k = 1 : numKernel
    K_tmp = X(:, k) * X(:, k)'; 
    if (isempty(componentDist))
        dist_k = pdist(X(:,k));
        componentDist_tmp =   dist_k .* dist_k;
        grad(k) = - 0.5*alpha_sv' * K_tmp(pos_sv,pos_sv) * alpha_sv + C_r/2 *componentDist_tmp(beta);
    else
        grad(k) = - 0.5*alpha_sv' * K_tmp(pos_sv,pos_sv) * alpha_sv + C_r/2 *componentDist(beta,k) ;
    end
end;
end
