function pval = lagrangepp( j , xdata, xval )
% pval = lagrangepp( j , xdata, xval )
% returns the value of the lagrange polynomial at each value in xval.
% j is the jth lagrange polynomial, j ranges from 0 to length(xdata)
% xdata is a set of specified points
% xval= the set of points where the lagrange function is to be evalauted 
% pval= an array of the values of the lagrange polynomial at each point in
% xval

% PC 08/15 
% MA 302
n=length(xdata);
pval = 1;
for i = 1 : n
  if i ~= j
    pval = pval .*(xval-xdata(i))*(1/(xdata(j)-xdata(i)));
  end
end
