function z=kn_bound(x,p)

% KN_BOUND    Normal Boundary Kernel Function for univariate data.
%
%             KN_BOUND(X,P) Evaluates a boundary kernel (based 
%             upon the Normal 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<4,
  a0=quad8('kn_int',-10,p,1,[],0);
  a1=quad8('kn_int',-10,p,1,[],1);
  a2=quad8('kn_int',-10,p,1,[],2);     
  for i=1:length(x),
    if x(i)<p,
      z(i)=((a2-a1*x(i))*knorm(x(i)))/(a0*a2-a1^2);
      else,
        z(i)=0;
    end;
  end; 
  else,
    z=knorm(x)';
end;