% GJACTEST A test for the generalized Jacobi measure.
%
clear a b mp iq idelta irout eps0 tc AB Mcap kount
global a b mp iq idelta irout eps0 tc AB
global Mcap kount
f1='%15.0f %5.0f %5.0f %12.3e %12.3e\n';
f2='                          %6.3f';
fprintf('\n')
disp('               Results for test example to GJACTEST')
disp('                        (using Stieltjes)')
%disp('                         (using Lanczos)')
fprintf('\n')
disp('             N    Ncap  kount    erra         errb')
fprintf('\n')
eps0=1e3*eps;
irout=1;
%irout=0; 
t1=-1; t2=0; t3=1; a=-.5; b=-.5; g=1;
tc=[[t1 b];[t2 g];[t3 a]];
tic
for N=[10 40 80 160]
  ab=r_gjacobi(N,a,b);
  bex=2*ones(N,1);
  k=(2:2:N-1)'; bex(k+1)=k.*(k-1)./((2*k).^2-1);
  k=(1:2:N-1)'; bex(k+1)=k.*(k+1)./((2*k).^2-1);
  erra=abs(ab(:,1)); errb=abs((ab(:,2)-bex(:))./bex(:));
  merra=max(erra); merrb=max(errb);
  fprintf(f1,N,Mcap,kount,merra,merrb)
end
t=toc;
fprintf('\n')
disp('                          timing')
fprintf(f2,t)
