bridge/class-master/depend/pari/src/basemath/QX_factor.c
/* use van Hoeij's knapsack algorithm */
use van Hoeij's knapsack algorithm
use van Hoeij ' s knapsack algorithm
static GEN
combine_factors(GEN target, GEN famod, GEN p, long klim)
{
  GEN la, B, A, res, L, pa, pb, listmod;
  long a,b, l, maxK, n = degpol(target);
  int done;
  pari_timer T;
  A = factor_bound(target);
  la = absi_shallow(leading_coeff(target));
  B = mului(n, sqri(mulii(la, root_bound(target)))); 
  (void)cmbf_precs(p, A, B, &a, &b, &pa, &pb);
  if (DEBUGLEVEL>2) timer_start(&T);
  famod = ZpX_liftfact(target, famod, pa, p, a);
  if (DEBUGLEVEL>2) timer_printf(&T, "Hensel lift (mod %Ps^%ld)", p,a);
  L = cmbf(target, famod, A, p, a, b, klim, &maxK, &done);
  if (DEBUGLEVEL>2) timer_printf(&T, "Naive recombination");
  res     = gel(L,1);
  listmod = gel(L,2); l = lg(listmod)-1;
  famod = gel(listmod,l);
  if (maxK > 0 && lg(famod)-1 > 2*maxK)
  {
    if (l!=1) A = factor_bound(gel(res,l));
    if (DEBUGLEVEL > 4) err_printf("last factor still to be checked\n");
    L = LLL_cmbf(gel(res,l), famod, p, pa, A, a, maxK);
    if (DEBUGLEVEL>2) timer_printf(&T,"Knapsack");
    setlg(res, l); res = shallowconcat(res, L);
  }
  return res;
}
static GEN combine_factors ( GEN target , GEN famod , GEN p , long klim ) { GEN la , B , A , res , L , pa , pb , listmod ; long a , b , l , maxK , n = degpol ( target ) ; int done ; pari_timer T ; A = factor_bound ( target ) ; la = absi_shallow ( leading_coeff ( target ) ) ; B = mului ( n , sqri ( mulii ( la , root_bound ( target ) ) ) ) ; ( void ) cmbf_precs ( p , A , B , & a , & b , & pa , & pb ) ; if ( DEBUGLEVEL > 2 ) timer_start ( & T ) ; famod = ZpX_liftfact ( target , famod , pa , p , a ) ; if ( DEBUGLEVEL > 2 ) timer_printf ( & T , " " , p , a ) ; L = cmbf ( target , famod , A , p , a , b , klim , & maxK , & done ) ; if ( DEBUGLEVEL > 2 ) timer_printf ( & T , " " ) ; res = gel ( L , 1 ) ; listmod = gel ( L , 2 ) ; l = lg ( listmod ) - 1 ; famod = gel ( listmod , l ) ; if ( maxK > 0 && lg ( famod ) - 1 > 2 * maxK ) { if ( l != 1 ) A = factor_bound ( gel ( res , l ) ) ; if ( DEBUGLEVEL > 4 ) err_printf ( " \n " ) ; L = LLL_cmbf ( gel ( res , l ) , famod , p , pa , A , a , maxK ) ; if ( DEBUGLEVEL > 2 ) timer_printf ( & T , " " ) ; setlg ( res , l ) ; res = shallowconcat ( res , L ) ; } return res ; }
use van Hoeij's knapsack algorithm
use van Hoeij ' s knapsack algorithm
/* = bound for S_2 */ /* remove last elt, possibly unfactored. Add all new ones. */