bridge/class-master/depend/pari/src/modules/mpqs.c
/* Given the partially populated handle, find the optimum place in the FB
 * to pick prime factors for A from.  The lowest admissible subscript is
 * index0_FB, but unless kN is very small, we stay away a bit from that.
 * The highest admissible is size_of_FB + 1, where the largest FB prime
 * resides.  The ideal corner is about (sqrt(kN)/M) ^ (1/omega_A),
 * so that A will end up of size comparable to sqrt(kN)/M;  experimentally
 * it seems desirable to stay slightly below this.  Moreover, the selection
 * of the individual primes happens to err on the large side, for which we
 * compensate a bit, using the (small positive) quantity MPQS_A_FUDGE.
 * We rely on a few auxiliary fields in the handle to be already set by
 * mqps_set_sieve_threshold() before we are called.
 * Return 1 on success, and 0 otherwise. */
Given the partially populated handle, find the optimum place in the FB
to pick prime factors for A from.  The lowest admissible subscript is
index0_FB, but unless kN is very small, we stay away a bit from that.
The highest admissible is size_of_FB + 1, where the largest FB prime
resides.  The ideal corner is about (sqrt(kN)/M) ^ (1/omega_A),
so that A will end up of size comparable to sqrt(kN)/M;  experimentally
it seems desirable to stay slightly below this.  Moreover, the selection
of the individual primes happens to err on the large side, for which we
compensate a bit, using the (small positive) quantity MPQS_A_FUDGE.
We rely on a few auxiliary fields in the handle to be already set by
mqps_set_sieve_threshold() before we are called.
Return 1 on success, and 0 otherwise.
Given the partially populated handle find the optimum place in the FB to pick prime factors for A from . The lowest admissible subscript is index0_FB but unless kN is very small we stay away a bit from that . The highest admissible is size_of_FB + 1 where the largest FB prime resides . The ideal corner is about ( sqrt ( kN ) / M ) ^ ( 1 / omega_A ) so that A will end up of size comparable to sqrt ( kN ) / M ; experimentally it seems desirable to stay slightly below this . Moreover the selection of the individual primes happens to err on the large side for which we compensate a bit using the ( small positive ) quantity MPQS_A_FUDGE . We rely on a few auxiliary fields in the handle to be already set by mqps_set_sieve_threshold () before we are called . Return 1 on success and 0 otherwise .
static int
mpqs_locate_A_range(mpqs_handle_t *h)
{
  long i = h->index0_FB + 2*(h->omega_A) - 4;
  double l2_target_pA;
  mpqs_FB_entry_t *FB = h->FB;
  h->l2_target_A = (h->l2sqrtkN - h->l2M - MPQS_A_FUDGE);
  l2_target_pA = h->l2_target_A / h->omega_A;
  while ((FB[i].fbe_p != 0) && (FB[i].fbe_flogp <= l2_target_pA)) i++;
#ifdef MPQS_DEBUG_LOCATE_A_RANGE
  err_printf("MPQS DEBUG: omega_A=%ld, index0=%ld, i=%ld\n",
             (long) h->omega_A, (long) h->index0_FB, i);
#endif
  if (i > h->size_of_FB - 3)
  { 
    pari_warn(warner,
        "MPQS: sizing out of tune, FB too small or\n\tway too few primes in A");
    return 0;
  }
  h->index2_FB = i - 1;
#ifdef MPQS_DEBUG_LOCATE_A_RANGE
  err_printf("MPQS DEBUG: index2_FB = %ld\n", i - 1);
#endif
  return 1;
}
static int mpqs_locate_A_range ( mpqs_handle_t * h ) { long i = h -> index0_FB + 2 * ( h -> omega_A ) - 4 ; double l2_target_pA ; mpqs_FB_entry_t * FB = h -> FB ; h -> l2_target_A = ( h -> l2sqrtkN - h -> l2M - MPQS_A_FUDGE ) ; l2_target_pA = h -> l2_target_A / h -> omega_A ; while ( ( FB [ i ] . fbe_p != 0 ) && ( FB [ i ] . fbe_flogp <= l2_target_pA ) ) i ++ ; #ifdef MPQS_DEBUG_LOCATE_A_RANGE err_printf ( " \n " , ( long ) h -> omega_A , ( long ) h -> index0_FB , i ) ; #endif if ( i > h -> size_of_FB - 3 ) { pari_warn ( warner , " \n \t " ) ; return 0 ; } h -> index2_FB = i - 1 ; #ifdef MPQS_DEBUG_LOCATE_A_RANGE err_printf ( " \n " , i - 1 ) ; #endif return 1 ; }
Given the partially populated handle, find the optimum place in the FB
 to pick prime factors for A from.
Given the partially populated handle find the optimum place in the FB to pick prime factors for A from .
/* i will be counted up to the desirable index2_FB + 1, and omega_A is never
   * less than 3, and we want
   *   index2_FB - (omega_A - 1) + 1 >= index0_FB + omega_A - 3,
   * so: */ /* find the sweet spot, normally shouldn't take long */ /* check whether this hasn't walked off the top end... */ /* The following should actually NEVER happen. */ /* this isn't going to work at all. */ /* GN20050723
   * assert: index0_FB + (omega_A - 3) [the lowest FB subscript eligible to
   * be used in picking primes for A]  plus  (omega_A - 2)  does not exceed
   * index2_FB  [the subscript from which the choice of primes for A starts,
   * putting omega_A - 1 of them at or below index2_FB, and the last and
   * largest one above, cf. mpqs_si_choose_primes() below].
   * Moreover, index2_FB indicates the last prime below the ideal size, unless
   * (when kN is very small) the ideal size was too small to use. */