function belowabove = vclassify2(x, y, tol)
%VCLASSIFY2 Below, on, or above the line x = y.
%   BELOWABOVE = VCLASSIFY2(X, Y, TOL) classifies the array of points
%   [X; Y] as being below, on, or above of the line x = y.
%   BELOWABOVE is -1 if the point is below the line,
%   0 if the point is on the line, and 1 if the point is above
%   the line.
%
%   A point is considered on the line if (X - Y) is inside the
%   range -TOL to +TOL.

n = length(x);
belowabove = zeros(1, n);

% it is important to assign the 'on' case last here
belowabove(x > y) = -1;
belowabove(x < y) = 1;
belowabove(abs(x - y) < tol) = 0;

