function r=flpteq(x,vl,tol)

%r=flpteq(x,vl,tol)
%
%floating point number equality
%checks to see if the floating point numbers of a matrix x are
%equal within some tolerance to the floating point numbers in vl.
%the tolerance is set as eps, Matlab's default floating point
%relative accuracy.

if nargin==2,
   tol=eps;
end;

[M,N]=size(x);
[P,Q]=size(vl);

if size(x)==size(vl),
r=zeros(M,N);
ind=find(abs(x(:)-vl(:))<tol);
r(ind)=1;

elseif min(size(x))==1 & min(size(vl))==1,
x=x(:);vl=vl(:);r=zeros(length(x(:)),1);
ind=find(abs(x-vl)<tol);
r(ind)=1;

elseif (P==M & Q==1) | (P==1 & Q==M),
vl=vl(:);
r=zeros(M,N);
for i=1:N,
ind=find(abs(x(:,i)-vl)<tol);
r(ind,i)=1;
end; 

elseif max(size(vl))==1,
r=zeros(M,N);
ind=find(abs(x-vl)<tol);
r(ind)=1;

end
