function k = expK(x1,x2,sigma)
% Gaussian Kernel function.

if nargin<3
      sigma=1;
  end
  [n1,d] = size(x1);
  [n2,d] = size(x2);
  k = exp(-sum((repmat(reshape(x1,n1,1,d),[1,n2,1]) ...
      - repmat(reshape(x2,1,n2,d),[n1,1,1])).^2,3)/(2*sigma));
  
