C语言数值算法程序大全

时间:2013-04-24 14:08:31
【文件属性】:
文件名称:C语言数值算法程序大全
文件大小:401KB
文件格式:RAR
更新时间:2013-04-24 14:08:31
c 程序 史无前例的全,很实用。看了就知道。 #include #include #include #include #include "nr.h" using namespace std; namespace { inline DP alen(const DP a, const DP b, const DP c, const DP d) { return sqrt((b-a)*(b-a)+(d-c)*(d-c)); } } void NR::anneal(Vec_I_DP &x, Vec_I_DP &y, Vec_IO_INT &iorder) { const DP TFACTR=0.9; bool ans; int i,i1,i2,idec,idum,j,k,nn,nover,nlimit,nsucc; static Vec_INT n(6); unsigned long iseed; DP path,de,t; int ncity=x.size(); nover=100*ncity; nlimit=10*ncity; path=0.0; t=0.5; for (i=0;i= n[0]) ++n[1]; nn=(n[0]-n[1]+ncity-1) % ncity; } while (nn<2); idec=irbit1(iseed); if (idec == 0) { n[2]=n[1]+int(abs(nn-1)*ran3(idum))+1; n[2] %= ncity; de=trncst(x,y,iorder,n); ans=metrop(de,t); if (ans) { ++nsucc; path += de; trnspt(iorder,n); } } else { de=revcst(x,y,iorder,n); ans=metrop(de,t); if (ans) { ++nsucc; path += de; reverse(iorder,n); } } if (nsucc >= nlimit) break; } cout << endl << "T = " << setw(12) << t; cout << " Path Length = " << setw(12) << path << endl; cout << "Successful Moves: " << nsucc << endl; t *= TFACTR; if (nsucc == 0) return; } }

网友评论

  • 程序很实用,注释没有,可能理解起来有困难。但是可参照William.H《C数值计算算法编程》一书,该程序应该就是书中的附带程序
  • 实用性强,指导作用比较大
  • 还是很有用的。。。
  • 只是而代码,不是书,下错了
  • 找了很久的资源,如果注释在多一点就好了
  • 东西挺好的,注释少了。不过可以理解,书本上的应该也是就这样
  • 赞一个!算法还是比较全的,就是注释说明再多一些就好了
  • 很不错,东西很全。。。。。。。