function [D] = mahalanobis_dist(ZI,ZJ,M)
m = size(ZJ,1);
D = zeros(m,1);
ZD = ZI-ZJ;

for i = 1:m
    D(i) = ZD(i,:)*M*ZD(i,:).';
end
end

