function [U,d]=Uconj_ext_lag(dig,n)
%UCONJ_EXT_LAG The matrix U of the extended Stenger conjecture 
%and its eigenvalues for a Laguerre weight function
%   [U,D]=UCONJ_EXT_LAG(DIG,N,A) generates, partly in DIG-digit
%   arithmetic, the NxN matrix U and its eigenvalues D for
%   generalized Laguerre polynomials with parameter A. The 
%   elements of U are computed by sufficiently high-order 
%   Gauss_Laguerre quadrature, guaranteeing 3-decimal accuracy 
%   for all eigenvalues.

global a ab sab0 ab0a 
eps0=.5e-03; ng=ceil(n/2);
U=zeros(n);
abn=ab(1:n,:); 
xwn=gauss(n,abn); xn=xwn(:,1);
err=1; d1=zeros(n,1); m=0;
ab0ang=ab0a(1:ng,:); xw0ang=gauss(ng,ab0ang);
x0ang=xw0ang(:,1); w0ang=xw0ang(:,2);
while err>eps0
  d0=d1; m=m+20; if m>500, error('m exceeds 500'); end
  sab0m=sab0(1:m,:); sxw0m=sgauss(dig,m,sab0m); xw0m=double(sxw0m);
  x0m=xw0m(:,1); w0m=xw0m(:,2);
  for j=1:n
    cn=xn(j);
    const=exp(-cn);
    for k=1:n
      s0=0;
      for i=1:ng
        lag=lagrange(n,xn,x0ang(i));
        s0=s0+w0ang(i)*lag(k);
      end
      s1=0;
      for i=1:m
        x=cn+x0m(i);
        lag=lagrange(n,xn,x);
        s1=s1+w0m(i)*lag(k)*x^a;
      end
      U(j,k)=s0-const*s1;
    end
  end
  digits(dig);
  sU=vpa(U); d=eig(sU);
  d1=double(d);
  err=errd(n,d1,d0);
%  [m err]
end
d=d1; U=double(sU);
[m err]
