Guest User

yafu/factor/nfs/snfs.c:261

a guest
Dec 9th, 2016
79
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void skew_snfs_params(fact_obj_t *fobj, nfs_job_t *job)
  2. {
  3. // examine the difference between scaled difficulty and difficulty for snfs jobs
  4. // and skew the r/a parameters accordingly.
  5. // the input job struct should have already been filled in by get_ggnfs_params()
  6. double oom_skew;
  7. double percent_skew;
  8. if (job->snfs == NULL)
  9. return;
  10.  
  11. // sdiff gets incremented by 1 for every 6 orders of magnitude difference
  12. // between the r/a norms.
  13. oom_skew = job->snfs->sdifficulty - job->snfs->difficulty;
  14.  
  15. if (job->snfs->poly->side == RATIONAL_SPQ)
  16. {
  17. // sieving on rational side means that side's norm is the bigger one
  18. if (oom_skew >= 4)
  19. {
  20. // for really big skew, increment the large prime bound as well
  21. job->lpbr++;
  22. job->mfbr += 2;
  23. // 5% for every 6 orders of magnitude difference between the norms
  24. percent_skew = oom_skew * 0.05;
  25. job->alim -= percent_skew*job->alim/5;
  26. job->rlim += percent_skew*job->rlim;
  27. }
  28.  
  29. if (oom_skew >= 5)
  30. {
  31. // for really big skew, increment the large prime bound as well
  32. job->lpbr++;
  33. job->mfbr += 2;
  34. }
  35.  
  36. if (oom_skew >= 6)
  37. {
  38. // for really really big skew, use 3 large primes
  39. job->mfbr = job->lpbr*2.9;
  40. job->rlambda = 3.6;
  41. }
  42.  
  43. // this *should* just change min_rels based on the new lpbr/a value
  44. if (oom_skew >= 4)
  45. get_ggnfs_params(fobj, job);
  46.  
  47. }
  48. else
  49. {
  50. // sieving on algebraic side means that side's norm is the bigger one
  51. if (oom_skew >= 4)
  52. {
  53. // for really big skew, increment the large prime bound as well
  54. job->lpba++;
  55. job->mfba += 2;
  56. // 5% for every 6 orders of magnitude difference between the norms
  57. percent_skew = oom_skew * 0.05;
  58. job->alim += percent_skew*job->alim;
  59. job->rlim -= percent_skew*job->rlim/5;
  60. }
  61.  
  62. if (oom_skew >= 5)
  63. {
  64. // for really big skew, increment the large prime bound as well
  65. job->lpba++;
  66. job->mfba += 2;
  67. }
  68.  
  69. if (oom_skew >= 6)
  70. {
  71. // for really really big skew, use 3 large primes
  72. job->mfba = job->lpba*2.9;
  73. job->alambda = 3.6;
  74. }
  75.  
  76. // this *should* just change min_rels based on the new lpbr/a value
  77. if (oom_skew >= 4)
  78. get_ggnfs_params(fobj, job);
  79. }
  80.  
  81. return;
  82. }
  83.  
  84. // ...
  85. // ...
  86. // ...
  87. // following begins at line 2640...
  88.  
  89. void snfs_scale_difficulty(snfs_t *polys, int npoly)
  90. {
  91. // poly degrees yielding very unbalanced norms are less desireable for sieving.
  92. // reflect this by scaling the difficulty of these polys. Since special-q can
  93. // bring the norm down on one side or another (at the expense of the other side),
  94. // we add one to the difficulty for every order of magnitude imbalance beyond 6
  95. // between the two sides (until we figure out something more accurate)
  96. int i;
  97.  
  98. for (i=0; i<npoly; i++)
  99. {
  100. double ratio, absa = fabs(polys[i].anorm), absr = fabs(polys[i].rnorm);
  101.  
  102. // slight preference to sieve on the algebraic side...
  103. if ((log10(absr) - 6) > log10(absa))
  104. {
  105. ratio = absr / absa;
  106. polys[i].poly->side = RATIONAL_SPQ;
  107. }
  108. else
  109. {
  110. ratio = absa / absr;
  111. polys[i].poly->side = ALGEBRAIC_SPQ;
  112. }
  113.  
  114. if (VFLAG > 1)
  115. printf("gen: anorm: %1.2e, rnorm: %1.2e, ratio: %1.2e, log10(ratio) = %1.2f\n",
  116. polys[i].anorm, polys[i].rnorm, ratio, log10(ratio));
  117. ratio = log10(ratio) / 6.;
  118.  
  119. if (ratio < 0.)
  120. ratio = 0.;
  121.  
  122. polys[i].sdifficulty = polys[i].difficulty + ratio;
  123. }
  124.  
  125. return;
  126. }
RAW Paste Data