function g=grad2kn(x,y,A,h)

% GRAD2KN     Gradient of bi-variate normal kernel.

[n,d]=size(A);

sum=zeros(2,length(x));

for i=1:n,
  x=(x-A(i,1)*ones(size(x)))/h;
  y=(y-A(i,2)*ones(size(y)))/h;
  sum(1,:)=sum(1,:)-x.*knorm(x,y);
  sum(2,:)=sum(2,:)-y.*knorm(x,y);
end;

g=sum/(n*h^3);
