% This computes gradient for IPM_DK.
%
% Jan 12, 2012

function [g,KXinvWKX] = gradient(X,w,MA,W,KtinvX,mu,blk)

m = size(w,1);
n = size(X,1);

[V,D] = svd(W);
VtKtinvX = V'*KtinvX;
KXinvWKX = VtKtinvX'*diag(diag(D).^(-1))*VtKtinvX;

g = MA'*(-svec(blk,KXinvWKX)) - mu*1./w + mu/(1-sum(w))*ones(m,1);

