main.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include <iomanip>
  2. #include "config.hpp"
  3. #include "coeffs.hpp"
  4. #include "polygon_generator.hpp"
  5. #include "avx_matrix.hpp"
  6. static const size_t numbers[]=
  7. {
  8. 1,
  9. 2,
  10. 7,
  11. 28,
  12. 124,
  13. 588,
  14. 2938,
  15. 15268,
  16. 81826,
  17. 449572,
  18. 2521270,
  19. 14385376,
  20. 83290424,
  21. 488384528,
  22. 2895432660,
  23. 17332874364,
  24. 104653427012,
  25. 636737003384
  26. };
  27. void box(string str){
  28. size_t w=str.size();
  29. cout<<"\u250c";
  30. for(size_t i=0;i<w+2;++i) cout<<"\u2500";
  31. cout<<"\u2510"<<endl;
  32. cout<<"\u2502 "<<str<<" \u2502"<<endl;
  33. cout<<"\u2514";
  34. for(size_t i=0;i<w+2;++i) cout<<"\u2500";
  35. cout<<"\u2518"<<endl;
  36. }
  37. void disp_info(){
  38. box("Compute Fp's series of Self Avoiding Polygon");
  39. cout<<endl;
  40. cout<<" Maximal length is "<<max_len<<endl;
  41. }
  42. int main(){
  43. cout<<std::setprecision(20);
  44. disp_info();
  45. compute_coeffs();
  46. size_t nb[max_len/2];
  47. Reel res[max_len/2];
  48. Reel coeff[max_len/2];
  49. for(size_t i=0;2*i<max_len;++i){
  50. nb[i]=0;
  51. res[i]=0;
  52. }
  53. PolygonGenerator gen;
  54. size_t total=0;
  55. Polygon P;
  56. while(gen.next()){
  57. P=gen.get();
  58. size_t l=P.length;
  59. ++nb[l/2-1];
  60. ++total;
  61. Reel fp=P.fp();
  62. res[l/2-1]+=fp;
  63. }
  64. Reel d=256;
  65. for(size_t i=1;2*i<max_len;++i){
  66. Reel l=2*i+2;
  67. cout<<endl<<"=== Length "<<l<<" ==="<<endl;
  68. Reel r=res[i];
  69. Reel n=2*l;
  70. coeff[i]=(n*r)/d;
  71. cout<<" > number : "<<nb[i]<<endl;
  72. cout<<" > value : "<<coeff[i]<<endl;
  73. d*=16;
  74. }
  75. cout<<endl<<">>> Total : "<<total<<endl;
  76. cout<<endl<<">>> Coefficients list : "<<endl;
  77. for(size_t i=1;2*i<max_len;++i){
  78. cout<<coeff[i]<<" ";
  79. }
  80. cout<<endl;
  81. }