bridge/class-master/depend/pari/src/modules/mpqs.c
/* NOTE: We used to divide log_multiplier by an extra factor 2, and in
 * compensation we were multiplying by 2 when the fbe_logp fields were being
 * filled in, making all those bytes even.  Tradeoff: the extra bit of
 * precision is helpful, but interferes with a possible sieving optimization
 * (artifically shift right the logp's of primes in A, and just run over both
 * arithmetical progressions  (which coincide in this case)  instead of
 * skipping the second one, to avoid the conditional branch in the
 * mpqs_sieve() loops).  We could still do this, but might lose a little bit
 * accuracy for those primes.  Probably no big deal. */
We used to divide log_multiplier by an extra factor 2, and in
compensation we were multiplying by 2 when the fbe_logp fields were being
filled in, making all those bytes even.  Tradeoff: the extra bit of
precision is helpful, but interferes with a possible sieving optimization
(artifically shift right the logp's of primes in A, and just run over both
arithmetical progressions  (which coincide in this case)  instead of
skipping the second one, to avoid the conditional branch in the
mpqs_sieve() loops).  We could still do this, but might lose a little bit
accuracy for those primes.  Probably no big deal.
We used to divide log_multiplier by an extra factor 2 and in compensation we were multiplying by 2 when the fbe_logp fields were being filled in making all those bytes even . Tradeoff : the extra bit of precision is helpful but interferes with a possible sieving optimization ( artifically shift right the logp ' s of primes in A and just run over both arithmetical progressions ( which coincide in this case ) instead of skipping the second one to avoid the conditional branch in the mpqs_sieve () loops ) . We could still do this but might lose a little bit accuracy for those primes . Probably no big deal .
static void
mpqs_set_sieve_threshold(mpqs_handle_t *h)
{
  mpqs_FB_entry_t *FB = h->FB;
  long i;
  double log_maxval;
  double log_multiplier;
  h->l2sqrtkN = 0.5 * log2(h->dkN);
  h->l2M = log2((double)h->M);
  log_maxval = h->l2sqrtkN + h->l2M - MPQS_A_FUDGE;
  log_multiplier = 232.0 / log_maxval;
  h->sieve_threshold =
    (unsigned char) (log_multiplier *
                     (log_maxval
                      - h->tolerance * log2((double)h->largest_FB_p)
                      )
                     ) + 1;
  if (h->sieve_threshold < 128) {
    h->sieve_threshold = 128;
    pari_warn(warner,
        "MPQS: sizing out of tune, FB size or tolerance\n\ttoo large");
  }
  if (DEBUGLEVEL >= 5)
  {
    err_printf("MPQS: computing logarithm approximations for p_i in FB\n");
  }
  for (i = h->index0_FB; i < h->size_of_FB + 2; i++)
  {
    FB[i].fbe_logval =
      (unsigned char) (log_multiplier * FB[i].fbe_flogp);
  }
}
static void mpqs_set_sieve_threshold ( mpqs_handle_t * h ) { mpqs_FB_entry_t * FB = h -> FB ; long i ; double log_maxval ; double log_multiplier ; h -> l2sqrtkN = 0.5 * log2 ( h -> dkN ) ; h -> l2M = log2 ( ( double ) h -> M ) ; log_maxval = h -> l2sqrtkN + h -> l2M - MPQS_A_FUDGE ; log_multiplier = 232.0 / log_maxval ; h -> sieve_threshold = ( unsigned char ) ( log_multiplier * ( log_maxval - h -> tolerance * log2 ( ( double ) h -> largest_FB_p ) ) ) + 1 ; if ( h -> sieve_threshold < 128 ) { h -> sieve_threshold = 128 ; pari_warn ( warner , " \n \t " ) ; } if ( DEBUGLEVEL >= 5 ) { err_printf ( " \n " ) ; } for ( i = h -> index0_FB ; i < h -> size_of_FB + 2 ; i ++ ) { FB [ i ] . fbe_logval = ( unsigned char ) ( log_multiplier * FB [ i ] . fbe_flogp ) ; } }
NOTE: We used to divide log_multiplier by an extra factor 2, and in
 compensation we were multiplying by 2 when the fbe_logp fields were being
 filled in, making all those bytes even.
NOTE : We used to divide log_multiplier by an extra factor 2 and in compensation we were multiplying by 2 when the fbe_logp fields were being filled in making all those bytes even .
/* That "+ 1" really helps - we may want to tune towards somewhat smaller
   * tolerances  (or introduce self-tuning one day)... */ /* If this turns out to be <128, scream loudly.
   * That means that the FB or the tolerance or both are way too
   * large for the size of kN.  (Normally, the threshold should end
   * up in the 150...170 range.) */ /* Now fill in the byte-sized approximate scaled logarithms of p_i */