diff -rupN code/cholesky.h code302/cholesky.h --- code/cholesky.h Thu May 10 14:24:12 2007 +++ code302/cholesky.h Tue Sep 16 17:25:12 2008 @@ -3,7 +3,6 @@ struct Cholesky{ MatDoub el; Cholesky(MatDoub_I &a) : n(a.nrows()), el(a) { Int i,j,k; - VecDoub tmp; Doub sum; if (el.ncols() != n) throw("need square matrix"); for (i=0;i -struct Dlinmin { - VecDoub &p; - VecDoub ξ - Doub &fret; - Df1dim df1dim; - Mnbrak mnbrak; - Dbrent dbrent; - Dlinmin(VecDoub_IO &pp, VecDoub_IO &xii, Doub &frett, T &funcd) : - p(pp), xi(xii), fret(frett), df1dim(p,xi,funcd) {} - void min() - { - const Doub TOL=1.0e-8; - Doub xx,xmin,fx,fb,fa,bx,ax; - Int n=p.size(); - ax=0.0; - xx=1.0; - mnbrak.bracket(ax,xx,bx,fa,fx,fb,df1dim); - fret=dbrent.min(ax,xx,bx,df1dim,TOL,xmin); - for (Int j=0;j170) throw("factorial overflows"); - return tab[i]; - } - - Doub facln(const Int i) { - if (i<0) throw("negative facln arg"); - if (in) throw("bico bad args"); - if (n<171) return floor(0.5+tab[n]/(tab[k]*tab[n-k])); - if (n struct VecInt htable, next, garbg; VecUllong thehash; hfnT hash; - Hashtable(Int nh, Int nv); + Hashtable(Int nh, Int nm); Int iget(const keyT &key); Int iset(const keyT &key); Int ierase(const keyT &key); @@ -60,9 +60,9 @@ template struct }; template -Hashtable::Hashtable(Int nh, Int nv): - hash(sizeof(keyT)), nhash(nh), nmax(nv), nn(0), ng(0), - htable(nh), next(nv), garbg(nv), thehash(nv) { +Hashtable::Hashtable(Int nh, Int nm): + hash(sizeof(keyT)), nhash(nh), nmax(nm), nn(0), ng(0), + htable(nh), next(nm), garbg(nm), thehash(nm) { for (Int j=0; j diff -rupN code/kdtree.h code302/kdtree.h --- code/kdtree.h Thu May 10 14:24:13 2007 +++ code302/kdtree.h Tue Sep 16 17:25:12 2008 @@ -53,7 +53,6 @@ template struct KDtree { Doub disti(Int jpt, Int kpt); Int locate(Point pt); Int locate(Int jpt); - Int nearest(Int jpt); Int nearest(Point pt); void nnearest(Int jpt, Int *nn, Doub *dn, Int n); static void sift_down(Doub *heap, Int *ndx, Int nn); diff -rupN code/linmin.h code302/linmin.h --- code/linmin.h Mon Apr 16 17:39:41 2007 +++ code302/linmin.h Wed Dec 31 17:00:00 1969 @@ -1,25 +0,0 @@ -template -struct Linmin { - VecDoub &p; - VecDoub ξ - Doub &fret; - F1dim f1dim; - Mnbrak mnbrak; - Brent brent; - Linmin(VecDoub_IO &pp, VecDoub_IO &xii, Doub &frett, T &func) : - p(pp), xi(xii), fret(frett), f1dim(p,xi,func) {} - void min() - { - const Doub TOL=1.0e-8; - Doub xx,xmin,fx,fb,fa,bx,ax; - Int n=p.size(); - ax=0.0; - xx=1.0; - mnbrak.bracket(ax,xx,bx,fa,fx,fb,f1dim); - fret=brent.min(ax,xx,bx,f1dim,TOL,xmin); - for (Int j=0;j big) { diff -rupN code/mins_ndim.h code302/mins_ndim.h --- code/mins_ndim.h Thu May 10 14:24:13 2007 +++ code302/mins_ndim.h Tue Sep 16 17:25:12 2008 @@ -187,7 +187,7 @@ struct Frprmn : Linemethod { fp=fret; func.df(p,xi); Doub test=0.0; - Doub den=MAX(fp,1.0); + Doub den=MAX(abs(fp),1.0); for (Int j=0;j test) test=temp; diff -rupN code/mnbrak.h code302/mnbrak.h --- code/mnbrak.h Mon Apr 16 17:39:41 2007 +++ code302/mnbrak.h Wed Dec 31 17:00:00 1969 @@ -1,60 +0,0 @@ -struct Mnbrak { - inline void shft3(Doub &a, Doub &b, Doub &c, const Doub d) - { - a=b; - b=c; - c=d; - } - template - void bracket(Doub &ax, Doub &bx, Doub &cx, Doub &fa, Doub &fb, Doub &fc, - T &func) - { - const Doub GOLD=1.618034,GLIMIT=100.0,TINY=1.0e-20; - Doub fu; - fa=func(ax); - fb=func(bx); - if (fb > fa) { - SWAP(ax,bx); - SWAP(fb,fa); - } - cx=bx+GOLD*(bx-ax); - fc=func(cx); - while (fb > fc) { - Doub r=(bx-ax)*(fb-fc); - Doub q=(bx-cx)*(fb-fa); - Doub u=bx-((bx-cx)*q-(bx-ax)*r)/ - (2.0*SIGN(MAX(abs(q-r),TINY),q-r)); - Doub ulim=bx+GLIMIT*(cx-bx); - if ((bx-u)*(u-cx) > 0.0) { - fu=func(u); - if (fu < fc) { - ax=bx; - bx=u; - fa=fb; - fb=fu; - return; - } else if (fu > fb) { - cx=u; - fc=fu; - return; - } - u=cx+GOLD*(cx-bx); - fu=func(u); - } else if ((cx-u)*(u-ulim) > 0.0) { - fu=func(u); - if (fu < fc) { - shft3(bx,cx,u,u+GOLD*(u-cx)); - shft3(fb,fc,fu,func(u)); - } - } else if ((u-ulim)*(ulim-cx) >= 0.0) { - u=ulim; - fu=func(u); - } else { - u=cx+GOLD*(cx-bx); - fu=func(u); - } - shft3(ax,bx,cx,u); - shft3(fa,fb,fc,fu); - } - } -}; diff -rupN code/mparith.h code302/mparith.h --- code/mparith.h Thu May 10 14:24:13 2007 +++ code302/mparith.h Tue Sep 16 17:25:12 2008 @@ -228,7 +228,7 @@ void MParith::mp2dfr(VecUchar_IO &a, str } } string MParith::mppi(const Int np) { - const Uint IAOFF=48,MACC=2; + const Uint MACC=2; Int ir,j,n=np+MACC; Uchar mm; string s; diff -rupN code/pade.h code302/pade.h --- code/pade.h Thu May 10 14:24:13 2007 +++ code302/pade.h Tue Sep 16 17:25:12 2008 @@ -1,10 +1,8 @@ Ratfn pade(VecDoub_I &cof) { - const Doub BIG=1.0e99; Int j,k,n=(cof.size()-1)/2; Doub sum; MatDoub q(n,n),qlu(n,n); - VecInt indx(n); VecDoub x(n),y(n),num(n+1),denom(n+1); for (j=0;j test) test=temp; diff -rupN code/ran.h code302/ran.h --- code/ran.h Thu May 10 14:24:13 2007 +++ code302/ran.h Tue Sep 16 17:25:12 2008 @@ -132,4 +132,3 @@ struct Ranlim32 { 2.32830643653869629E-10 * int32() ); } }; - diff -rupN code/rlftfrag.h code302/rlftfrag.h --- code/rlftfrag.h Mon Apr 16 17:39:41 2007 +++ code302/rlftfrag.h Wed Dec 31 17:00:00 1969 @@ -1,60 +0,0 @@ -Int main(void) // example1 -{ - const Int N2=256,N3=256; - NRMat3d data(1,N2,N3); - MatDoub speq(1,2*N2); - -// ... - rlft3(data,speq,1); -// ... - rlft3(data,speq,-1); -// ... - return 0; -} - -Int main(void) // example2 -{ - const Int N1=32,N2=64,N3=16; - NRMat3d data(N1,N2,N3); - MatDoub speq(N1,2*N2); -// ... - rlft3(data,speq,1); -// ... - return 0; -} - -Int main(void) // example3 -{ - Int j; - Doub fac,r,i,*sp1,*sp2; - const Int N=32; - NRMat3d data1(N,N,N),data2(N,N,N); - MatDoub speq1(N,2*N),speq2(N,2*N); -// ... - rlft3(data1,speq1,1); - rlft3(data2,speq2,1); - fac=2.0/(N*N*N); - sp1 = &data1[0][0][0]; - sp2 = &data1[0][0][0]; - for (j=0;jsing) throw("singular Jacobian in broydn"); + if (qr->sing) { + MatDoub one(n,n,0.0); + for (i=0;irsolve(p,p); + Doub slope=0.0; + for (i=0;i= 0.0) { + restrt=true; + continue; + } lnsrch(xold,fold,g,p,x,f,stpmax,check,fmin); test=0.0; for (i=0;i m || nl+nr < m) throw("bad args in savgol"); - VecInt indx(m+1); MatDoub a(m+1,m+1); VecDoub b(m+1); for (ipj=0;ipj<=(m << 1);ipj++) { diff -rupN code/series.h code302/series.h --- code/series.h Thu May 10 14:24:13 2007 +++ code302/series.h Tue Sep 16 17:25:12 2008 @@ -106,4 +106,3 @@ struct Levin { return (lastval = val); } }; - diff -rupN code/simplex.h code302/simplex.h --- code/simplex.h Thu May 10 14:24:13 2007 +++ code302/simplex.h Tue Sep 16 17:25:12 2008 @@ -161,16 +161,25 @@ void Simplex::solve() if (verbose) cout << " at end of phase0,iter= " << nsteps << endl; if (ierr != 0) { + delete lu; + for (Int i=0;i