function ab=sr_ggegenbauer(dig,N,a,c)
%SR_GGEGENBAUER Recurrence coefficients for generalized
%Gegenbauer polynomials
%   AB=SR_GGEGENBAUER(DIG,N,A,C) generates in DIG-digit
%   arithmetic the Nx2 array AB of the first N recurrence
%   coefficients for the generalized Gegenbauer weight function
%   w(x)=|x|^C*(1-x^2)^A on [-1,1], A>-1, C>-1.

digits(dig); sa=vpa(a); sc=vpa(c); s1=vpa(1); s2=vpa(2);
s3=vpa(3);
ab=vpa(zeros(N,2));
ab(1,2)=gamma((sc+s1)/s2)*gamma(sa+s1)/gamma((sc+s1)/s2+sa+s1);
if N==1, return; end
ab(2,2)=(sc+s1)/(s2*sa+sc+s3);
if N==2, return; end
for n=3:N
  k=vpa(n-1); if 2*floor(n/2)==n, s=s1; else s=vpa(0); end
  ab(n,2)=(k+s*sc)*(k+2*sa+s*sc)/ ... 
    ((2*k-1+s2*sa+sc)*(2*k+1+s2*sa+sc));
end
