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

function [g,invX,KXK] = gradient(X,w,MA,mu,blk)

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

[V,D] = svd(X);
invX = V*diag(diag(D).^(-1))*V';
KXK = V*diag(diag(D).^(-2))*V';

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

