subroutine resolv(ALPHA,AN,ANPI,a,sigmac,sigmaa,flamda,nterms, * chisqr,ap,scale,V,evv,chisq,iv,icheck,frsum,DMAT,npts) c c calculate resolution and uncertainty in the model c parameters from MJSANL. c c ALPHA = curvature matrix c AN = normalized curvature matrix c ANPI = inverse of ANP = AN ( 1 + diag(lambda) ) c a = parameter vector c flamda = Marquart parameter used by Bevington c R = parameter resolution matrix = G**-g G c XN = data resolution matrix = G G**-g c m = model vector ( m = delta a / a ) c d = data vector c G = linearized model matrix ( Gm = d ) c GTG = transpose of G times G c GGT = G times transpose of G c evv = eigenvalues of GTG c V = eigenvectors of GTG as columns c evu = eigenvalues of GGT c U = eigenvectors of GGT as columns c real*8 AN,ANPI,R integer*4 iv,icheck,npts dimension ALPHA(50,50),AN(50,50),ANPI(50,50),XN(512,512) dimension GTG(50,50),R(50,50),a(50),ap(50),rr(512) dimension evv(50),V(50,50),ratio(50),sigmaa(50),sigmac(50) dimension dmat(512,50),GGT(512,512),U(512,512),evu(512) c c normalization vector c isvd = 0 idat = 0 1 write(6,200) (a(i),i=1,nterms) ip=-10 101 WRITE(*,'(/1X,A)') 'ANY TRUE VECTORS? (1=YES, 0=NO)' read(5,*,end=101) itv if (itv.eq.1) then 201 WRITE(*,'(/1X,A)') 'WHICH PARAMETER IS THE FIRST COMPONENT?' read(5,*,end=201) ip vnorm = sqrt(a(ip)**2+a(ip+1)**2+a(ip+2)**2) endif do 4 i = 1,nterms if (i.eq.ip .or. i.eq.ip+1 .or. i.eq.ip+2) then ap(i)=vnorm else ap(i)=a(i) endif 4 continue c c calculate R and GTG c do 10 j = 1,nterms do 20 k = 1,nterms R(j,k) = 0. GTG(j,k) = ap(j)*ap(k)*ALPHA(j,k) do 30 i = 1,nterms 30 R(j,k) = R(j,k)+(ap(k)/ap(j))*sqrt(ALPHA(k,k)/ALPHA(j,j)) * *ANPI(j,i)*AN(i,k) 20 continue 10 continue c c eigenvalues and eigenvectors of GTG c c call jacobi(GTG,nterms,50,evv,V,nrot) c 111 do 31 i = 1,nterms do 32 j = 1,nterms V(i,j) = GTG(i,j) 32 continue 31 continue call tred2(V,nterms,50,evv,rr) call tqli(evv,rr,nterms,50,V) call eigsrt(evv,V,nterms,50) c c scale eigenvalues to give relative uncertainties in the fit c projection along corresponding eigenvectors c sigma = sqrt(chisqr/scale) do 37 i = 1,nterms evv(i) = evv(i)/chisqr 37 continue c c calculate resolution matrix for s.v.d. inverse c if (isvd.eq.2) then do 11 j = 1,nterms do 27 k = 1,nterms R(j,k) = 0. do 33 i = 1,ivnum R(j,k) = R(j,k)+V(j,i)*V(k,i) 33 continue 27 continue 11 continue endif 921 write (6,'(/1X,A)') 'DATA SPACE ANALYSIS? 1=YES, 0=NO' read(5,*,end=921) idat if(idat.eq.0) go to 91 if(npts.gt.32) then 923 write (6,'(/1X,A)') 'RUNNING TIME WILL BE LONG. STILL DO * DATA SPACE ANALYSIS? 1=YES, 0=NO' read(5,*,end=923) idat if(idat.eq.0) go to 91 endif c c calculate GGT c do 17 j = 1,npts do 57 k = 1,npts GGT(j,k) = 0. do 47 i = 1,nterms GGT(j,k) = GGT(j,k)+ap(i)*ap(i) * *dmat(j,i)*dmat(k,i)/(sigma*sigma) 47 continue 57 continue 17 continue c c calculate XN c do 97 i = 1,npts do 96 j = 1,npts XN(i,j) = 0. do 95 k = 1,nterms do 94 l = 1,nterms XN(i,j) = XN(i,j)+chisqr*(ANPI(k,l)/sqrt(ALPHA(k,k)* * ALPHA(l,l)))*dmat(i,k)*dmat(j,l)/(sigma*sigma) 94 continue 95 continue 96 continue 97 continue c c eigenvalues and eigenvectors of GGT c 922 write (6,'(/1X,A)') * 'CALCULATE DATA SPACE EIGENVECTORS? 1=YES, 0=NO' read(5,*,end=921) idvec if(idvec.eq.0) go to 91 do 38 i = 1,npts do 39 j = 1,npts U(i,j) = GGT(i,j) 39 continue 38 continue call tred2(U,npts,512,evu,rr) call tqli(evu,rr,npts,512,U) call eigsrt(evu,U,npts,512) c c printed output c 91 call clrtek if(icheck.eq.1) write(6,121) iv,frsum 121 format(' UNCERTAINTY TEST FOR EIGENVECTOR', * i3,' (',f5.2,' SIGMA)') write(6,100) flamda, sigma, chisq 100 format(/,/,' flamda = ',e9.2,' sigma = ',e11.4,' fA', * ' chisqr = ',f7.3) c c change format if nterms greater than 10 c if(nterms.lt.10) then write(6,200) (a(i),i=1,nterms) if(icheck.eq.0) write(6,205) (sigmaa(i),i=1,nterms) if(icheck.eq.0) write(6,205) (sigmac(i),i=1,nterms) write(6,210) (evv(i),i=1,nterms) write(6,250) do 40 j = 1,nterms 40 write(6,300) (V(j,k), k=1,nterms) else write(6,202) (a(i),i=1,nterms) if(icheck.eq.0) write(6,206) (sigmaa(i),i=1,nterms) if(icheck.eq.0) write(6,206) (sigmac(i),i=1,nterms) write(6,211) (evv(i),i=1,nterms) write(6,250) do 43 j = 1,nterms 43 write(6,301) (V(j,k), k=1,nterms) endif 200 format(/,' parameters:',/,/xxx,50f9.4) 202 format(/,' parameters:',/,/xxx,50f7.2) 205 format(/xxx,50f9.4) 206 format(/xxx,50f7.2) 210 format(/,' eigenvalues:',/,/xxx,50e9.2) 211 format(/,' eigenvalues:',/,/xxx,50e9.2) 250 format(/,/,' eigenvectors:',/) 300 format(xxx,50f9.3) 301 format(xxx,50f7.3) if (flamda.eq.0.) then write(6,410) else if (isvd.eq.2) then write(6,411) ivnum else write(6,400) endif endif 410 format(/,/,' GTG matrix:',/) 400 format(/,/,' resolution matrix:',/) 411 format(/,/,' resolution matrix (s.v.d. ',i3,' eigenvectors):',/) do 50 j = 1,nterms if (flamda.eq.0. .and. isvd.ne.2) then if (nterms.lt.10) then write(6,510) (GTG(j,k)/chisqr, k=1,nterms) else write(6,511) (GTG(j,k)/chisqr, k=1,nterms) endif else if (nterms.lt.10) then write(6,500) (R(j,k), k=1,nterms) else write(6,501) (R(j,k), k=1,nterms) endif endif 50 continue 510 format(xxx,50e9.2) 511 format(xxx,50e7.2) 500 format(xxx,50f9.4) 501 format(xxx,50f7.4) read(5,*) x call clrtek if (idat.eq.1) then if (npts.lt.30) then write (6,'(/1x,a,/)') 'data resolution matrix:' do 53 j = 1,npts write(6,500) (XN(j,k), k=1,npts) 53 continue read(5,*) x call clrtek endif endif if (idvec.eq.1) then if (npts.gt.12) then write(6,216) (evu(i),i=1,nterms) else write(6,216) (evu(i),i=1,npts) endif 216 format(/,' eigenvalues of GGT:',/,/xxx,50e9.2) write (6,'(/1x,a,/)') 'eigenvectors of GGT:' do 54 j = 1,npts if (npts.gt.12) then write(6,300) (U(j,k), k=1,nterms) else write(6,300) (U(j,k), k=1,npts) endif 54 continue read(5,*) x call clrtek endif c C Eigenvector test DO 23 J=1,nterms DO 21 L=1,nterms rr(L)=0.0 DO 19 K=1,nterms IF (K.GT.L) THEN KK=L LL=K ELSE KK=K LL=L ENDIF rr(L)=rr(L)+GTG(LL,KK)*V(K,J) 19 CONTINUE 21 CONTINUE WRITE(*,'(/1X,A,I3)') 'Vector Number',J DO 22 L=1,nterms RATIO(L)=rr(L)/(V(L,J)*chisqr) 22 CONTINUE write(6,230) (ratio(i),i=1,nterms) 230 format(/,xxx,50e12.4) 23 CONTINUE read(5,*) x c write(6,217) (evv(i),i=1,nterms) c 217 format(/,' eigenvalues of GTG:',/,/xxx,50e9.2) c write(6,218) (evu(i),i=1,npts) c 218 format(/,' eigenvalues of GTG:',/,/xxx,512e9.2) 171 WRITE(*,'(/1X,A)') 'RECALCULATE? 1=YES, 0=NO, 2=S.V.D. RESOLUTION' read(5,*,end=171) isvd if (isvd.eq.0) return if (isvd.eq.1) go to 1 if (isvd.eq.2) then 181 WRITE(*,'(/1X,A)') 'HOW MANY EIGENVECTORS?' read(5,*,end=181) ivnum go to 1 endif go to 171 end