function ab=r_hatfcn_mcheb(N)
%R_HATFCN_MCHEB  Recurrence coefficients for the hat weight
%function.
%   R_HATFCN_MCHEB(N) generates the first N recurrence
%   coefficients for the weight function W(X)=1+X if
%   -1 <= X <= 0, 1-X if 0 <= X <= 1, and 0 otherwise,
%   using the modified Chebyshev algorithm.

P=zeros(N);
abl=r_jacobi(2*N-1); abj=r_jacobi01(N);
xwj=gauss(N,abj); xj=xwj(:,1); wj=xwj(:,2);
for j=1:N
  P(:,j)=mope(N,xj(j),abl);
end
mom=zeros(1,2*N);
for k=1:N
  mom(2*k-1)=2*sum(wj.*(1-xj).*P(k,:)');
end
ab=chebyshev(N,mom,abl);
