function z=kb_bound(x,p)

% KB_BOUND    Bi-weight Boundary Kernel Function for univariate data.
%
%             KB_BOUND(X,P) Evaluates a boundary kernel (based 
%             upon the Bi-weight kernel) at X.  The value P is
%             a measure of how close the data point is to the 
%             boundary (assumed to be zero).
%
%             Christian C. Beardah 1994

if p>1,
  p=1;
  a0=1;
  a1=0;
  a2=quad8('kb_int',-1,p,1,[],2);
  else,
    a0=quad8('kb_int',-1,p,1,[],0);
    a1=quad8('kb_int',-1,p,1,[],1);
    a2=quad8('kb_int',-1,p,1,[],2);     
end;

for i=1:length(x),
  if x(i)<p,
    z(i)=((a2-a1*x(i))*kb(x(i)))/(a0*a2-a1^2);
    else,
      z(i)=0;
  end;
end;