function [U,d,xn,flxn]=Uconj_ext_blockhahn(dig,n)
%CONJ_EXT_BLOCKHAHN The matrix U of the extended Stenger conjecture 
%and its eigenvalues for the (N+1)-block Hahn weight function
%   [U,D,XN,FLXN]=UCONJ_EXT_BLOCKHAHN(DIG,n) generates, partly in
%   DIG-digit arithmetic, the nxn matrix U and its eigenvalues
%   D for the (N+1)-block Hahn weight function w(x;N+1,a,b). The 
%   elements of U are computed exactly, in part by floor(n/2)-point
%   Gauss-Legendre quadrature on [0,1]. The output variables XN
%   and FLXN are the DIG-digit zeros and their floors of the 
%   nth-degree orthogonal polynomial. 

global N ab ab0 w
U=zeros(n); ng=ceil(n/2);
abn=ab(1:n,:); ab0ng=ab0(1:ng,:); 
xwn=gauss(n,abn); xn=xwn(:,1); flxn=floor(xn);
xwng=gauss(ng,ab0ng); xng=xwng(:,1); wng=xwng(:,2);
for j=1:n
  xj=xn(j); 
  m=flxn(j); 
  for k=1:n
    if m ~= 2*floor(m/2)
      si=0;
      for i=0:(m-1)/2
        s=0;
        for r=1:ng
          lag=lagrange(n,xn,2*i+xng(r));
          s=s+wng(r)*lag(k);
        end
        si=si+w(i+1)*s;
      end
      U(j,k)=si;
    else
      if m==0
        s=0;
        for r=1:ng
          lag=lagrange(n,xn,xj*xng(r));
          s=s+wng(r)*lag(k);
        end
        U(j,k)=w(1)*xj*s;
      else
        si=0;
        for i=0:(m-2)/2
          s=0;
          for r=1:ng
            lag=lagrange(n,xn,2*i+xng(r));
            s=s+wng(r)*lag(k);
          end
          si=si+w(i+1)*s;
        end 
        s=0;
        for r=1:ng
          lag=lagrange(n,xn,(xj-m)*xng(r)+m);
          s=s+wng(r)*lag(k);
        end
        U(j,k)=si+w(m/2)*(xj-m)*s;
      end
    end
  end
end
digits(dig);
sU=vpa(U); d=eig(sU);
d=double(d);
