function dist = H_dist(a,b)
% Computes Hausdorf distance between column vectors a and b
% entries of a,b is between 0 and 1
% distance is computed on Torus = [0,1)

% a = [.1 .5 .7]';
% b = [.13 .56 .78]';

if size(a,2) ~= 1
    a = a.';
end
if size(b,2) ~= 1
    b = b.';
end
    

La = length(a);
Lb = length(b);

distab = 0;
for k = 1 : La
    distab = max(distab,min(min(abs(a(k)-b),1-abs(a(k)-b))));
end

distba = 0;
for k = 1 : Lb
    distba = max(distba,min(min(abs(b(k)-a),1-abs(b(k)-a))));
end

dist = max(distab,distba);