% the orignal method has been developed by Piotr Dollar
% for a very fast computation of the squared distances between
% a set of points - here it has been changed and contains a bug
% THIS IS FOR TEACHING PURPOSES - IT CONTAINS A BUG !
 
function D = dist_euclidean( X, Y )
    if( ~isa(X,'double') || ~isa(Y,'double'))
        error( 'Inputs must be of type double'); end;
    m = size(X,1); n = size(Y,1);  
    Yt = Y';  
    XX = sum(X.*X,2);        
    YY = sum(Yt.*Yt,2);      
    D = XX(:,ones(1,n)) + YY(ones(1,m),:) - 2*X*Yt;
