function [U,d]=Uconj_ext_herm(dig,n)
%UCONJ_EXT_HERM The matrix U of the extended Stenger conjecture 
%and its eigenvalues for generalized Hermite weight functions
%   [U,D]=UCONJ_EXT_HERM(DIG,N,MU) generates, partly in DIG-digit
%   arithmetic, the NxN matrix U and its eigenvalues D for
%   generalized Hermite polynomials with parameter MU. The 
%   elements of U are computed by 32-digit half-range Hermite
%   quadrature and shifted Gauss-Jacobi quadrature (when x_j >= 0).

global mu ab sabhrh abjac 
if mu>85, error('mu exceeds 85'); end
abhrh=double(sabhrh);
eps0=.5e-03; ng=ceil(n/2+mu);
abng=abhrh(1:ng,:); xwng=gauss(ng,abng); 
xng=xwng(:,1); wng=xwng(:,2);
U=zeros(n);
abn=ab(1:n,:); 
xwn=gauss(n,abn); xn=xwn(:,1);
err=1; d1=zeros(n,1); m=0;
while err>eps0
  d0=d1; m=m+10; if m>100, error('m exceeds 100'); end
  sabhrhm=sabhrh(1:m,:); sxwhrhm=sgauss(dig,m,sabhrhm); 
  xwhrhm=double(sxwhrhm); xhrhm=xwhrhm(:,1); whrhm=xwhrhm(:,2);
  for k=1:n
    for j=1:n
      cn=xn(j); cn2=cn^2;
      if cn<0
        s0=0;
        for i=1:m
          x=cn-xhrhm(i);
          lag=lagrange(n,xn,x);
          s0=s0+whrhm(i)*lag(k)*(-x)^(2*mu)*exp(2*cn*xhrhm(i));
        end
        U(j,k)=exp(-cn2)*s0;
      else
        s1=0;
        for i=1:ng
          lag=lagrange(n,xn,-xng(i));
          s1=s1+wng(i)*lag(k)*xng(i)^(2*mu);
        end 
        xwjacm=gauss(m,abjac); 
        xjacm=xwjacm(:,1); wjacm=xwjacm(:,2);
        s2=0;
        for i=1:m
          lag=lagrange(n,xn,cn*xjacm(i));
          s2=s2+wjacm(i)*lag(k)*exp(-cn2*xjacm(i)^2);
        end
        U(j,k)=s1+cn^(2*mu+1)*s2;
      end
    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]
