function [ab,Mcap,err,kount]=r_marchenko_pastur_dis(N,nofdig)
%R_MARCHENKO_PASTUR_DIs Recurrence coefficients for the generalized
%Marchenko-Pastur probability measure.
%   [AB,MCAP,ERR,KOUNT]=R_MARCHENKO_PASTUR_DIS(N,NOFDIG) uses a 
%   discretization procedure based on Gaussian quadrature to generate
%   the first N recurrence coefficients for the generalized
%   Marchenko-Pastur probability measure with parameters ALPHA, BETA,
%   and C. These parameters must be specified and declared global in
%   a driver routine (see, e.g., run_marchenko_pastur_dis.m), which
%   also determines the number DIG, and declares it global, of digits
%   required to obtain the recurrence coefficients to NOFDIG correct 
%   digits. The recurrence coefficients are placed to NOFDIG digits 
%   into the Nx2 array AB. The output parameters MCAP, ERR, KOUNT are 
%   inherited from the discretization routine smcdis.m.

global mc mp iq idelta irout DM abmp dig alpha beta c
if c<1
  mp=0;
else
  mp=1;
end
digits(dig);
sc=vpa(c); s1=vpa(1); s0=vpa(0);
abmp=r_marchenko_pastur_mod(dig,N+1,alpha,beta,c);  
if c<1
  ty=[s0,s0]; abmp(1,2)=s1;
else
  ty=[s0,s1-s1/sc]; abmp(1,2)=s1/sc;
end
mc=1; iq=1; idelta=2; irout=1; DM=ty;
eps0=.5*10^(-nofdig); Mmax=500; %Mmax=N+1;
[ab,Mcap,kount]=smcdis(N,eps0,@squad_marchenko_pastur_dis,Mmax);
