Changeset 4578 for trunk/GSASIImath.py
 Timestamp:
 Sep 28, 2020 1:23:10 PM (3 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIImath.py
r4560 r4578 166 166 Lam = np.zeros((n,n)) 167 167 Xvec = np.zeros(len(x0)) 168 chisq00 = None 168 169 while icycle < maxcyc: 169 170 time0 = time.time() … … 172 173 nfev += 1 173 174 chisq0 = np.sum(M**2) 175 if chisq00 is None: chisq00 = chisq0 174 176 Yvec,Amat = Hess(x0,*args) 175 177 Adiag = np.sqrt(np.diag(Amat)) … … 234 236 Bmat = Bmat/Anorm 235 237 return [x0,Bmat,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':lamMax,'psing':[], 236 'SVD0':Nzero,'Converged': ifConverged, 'DelChi2':deltaChi2,'Xvec':Xvec }]238 'SVD0':Nzero,'Converged': ifConverged, 'DelChi2':deltaChi2,'Xvec':Xvec, 'chisq0':chisq00}] 237 239 except nl.LinAlgError: 238 240 G2fil.G2Print('ouch #2 linear algebra error in making vcov matrix', mode='error') … … 240 242 if maxcyc: 241 243 psing = list(np.where(np.diag(nl.qr(Amat)[1]) < 1.e14)[0]) 242 return [x0,None,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':lamMax,'psing':psing,'SVD0':1,'Xvec':None }]244 return [x0,None,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':lamMax,'psing':psing,'SVD0':1,'Xvec':None, 'chisq0':chisq00}] 243 245 244 246 def HessianSVD(func,x0,Hess,args=(),ftol=1.49012e8,xtol=1.e6, maxcyc=0,lamda=3,Print=False,refPlotUpdate=None): … … 298 300 if Print: 299 301 G2fil.G2Print(' Hessian SVD refinement on %d variables:'%(n)) 302 chisq00 = None 300 303 while icycle < maxcyc: 301 304 time0 = time.time() … … 303 306 nfev += 1 304 307 chisq0 = np.sum(M**2) 308 if chisq00 is None: chisq00 = chisq0 305 309 Yvec,Amat = Hess(x0,*args) 306 310 Adiag = np.sqrt(np.diag(Amat)) … … 347 351 Bmat = Bmat/Anorm 348 352 return [x0,Bmat,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':0.,'psing':[], 349 'SVD0':Nzero,'Converged': ifConverged, 'DelChi2':deltaChi2}] 353 'SVD0':Nzero,'Converged': ifConverged, 'DelChi2':deltaChi2, 354 'chisq0':chisq00}] 350 355 except nl.LinAlgError: 351 356 G2fil.G2Print('ouch #2 linear algebra error in making vcov matrix', mode='error') … … 353 358 if maxcyc: 354 359 psing = list(np.where(np.diag(nl.qr(Amat)[1]) < 1.e14)[0]) 355 return [x0,None,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':0.,'psing':psing,'SVD0':1}] 360 return [x0,None,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':0.,'psing':psing,'SVD0':1, 361 'chisq0':chisq00}] 356 362 357 363 def getVCov(varyNames,varyList,covMatrix):
Note: See TracChangeset
for help on using the changeset viewer.