function d = dist2(xt, x)
%DIST	calculate distances between multiple points
%	d = dist2(xt, x);
%
%	xt: points (2 * M)
%	x : points (2 * N)
%	d : distances' square (M*N)

%	Ling Li, Caltech
%	11/11/2000

N = size(x, 2);
M = size(xt, 2);

d1 = repmat(reshape(xt(1,:), M, 1), 1, N) - repmat(x(1,:), M, 1);
d2 = repmat(reshape(xt(2,:), M, 1), 1, N) - repmat(x(2,:), M, 1);
d = d1.^2 + d2.^2;

