bridge/class-master/depend/pari/src/basemath/base2.c
/* return 1 if at least 2 factors mod p ==> chi can be split */
return 1 if at least 2 factors mod p ==> chi can be split
return 1 if at least 2 factors mod p == > chi can be split
static int
loop(decomp_t *S, long Ea)
{
  pari_sp av = avma;
  GEN beta = FpXQ_powu(S->nu, Ea, S->chi, S->p);
  long N = degpol(S->f), v = varn(S->f);
  S->invnu = NULL;
  for (;;)
  { 
    long L, i, Fg, eq, er;
    GEN chig = NULL, d, g, nug;
    if (DEBUGLEVEL>4) err_printf("  beta = %Ps\n", beta);
    L = ZpX_resultant_val(S->chi, beta, S->p, S->mf+1);
    if (L > S->mf) L = -1; 
    g = get_g(S, Ea, L, N, beta, &chig, &eq, &er);
    if (DEBUGLEVEL>4) err_printf("  (eq,er) = (%ld,%ld)\n", eq,er);
    if (split_char(S, chig, g,S->phi, &nug)) return 1;
    Fg = degpol(nug);
    if (Fg == 1)
    { 
      long Le, Ee;
      GEN chie, nue, e, pie;
      d = negi(gel(nug,2));
      chie = RgX_translate(chig, d);
      nue = pol_x(v);
      e = RgX_Rg_sub(g, d);
      pie = getprime(S, e, chie, nue, &Le, &Ee,  0,Ea);
      if (pie) return testc2(S, S->nu, Ea, pie, Ee);
    }
    else
    {
      long Fa = degpol(S->nu), vdeng;
      GEN deng, numg, nume;
      if (Fa % Fg) return testb2(S, ulcm(Fa,Fg), g);
      if (ZX_equal(nug, S->nu))
        d = pol_x(v);
      else
      {
        if (!p_is_prime(S)) pari_err_PRIME("FpX_ffisom",S->p);
        d = FpX_ffisom(nug, S->nu, S->p);
      }
      numg = QpX_remove_denom(g, S->p, &deng, &vdeng);
      for (i = 1; i <= Fg; i++)
      {
        GEN chie, nue, e;
        if (i != 1) d = FpXQ_pow(d, S->p, S->nu, S->p); 
        nume = ZX_sub(numg, ZX_Z_mul(d, deng));
        if (ZpX_resultant_val(S->chi, nume, S->p, vdeng*N+1) <= vdeng*N)
          continue;
        e = RgX_Rg_div(nume, deng);
        chie = mycaract(S, S->chi, e, S->psc, S->prc);
        if (split_char(S, chie, e,S->phi, &nue)) return 1;
        if (RgX_is_monomial(nue))
        { 
          long Le, Ee;
          GEN pie;
          pie = getprime(S, e, chie, nue, &Le, &Ee,  0,Ea);
          if (pie) return testc2(S, S->nu, Ea, pie, Ee);
          break;
        }
      }
      if (i > Fg)
      {
        if (!p_is_prime(S)) pari_err_PRIME("nilord",S->p);
        pari_err_BUG("nilord (no root)");
      }
    }
    if (eq) d = gmul(d, powiu(S->p,  eq));
    if (er) d = gmul(d, gpowgs(S->nu, er));
    beta = gsub(beta, d);
    if (gc_needed(av,1))
    {
      if (DEBUGMEM > 1) pari_warn(warnmem, "nilord");
      gerepileall(av, S->invnu? 6: 4, &beta, &(S->precns), &(S->ns), &(S->nsf), &(S->invnu), &(S->Dinvnu));
    }
  }
}
static int loop ( decomp_t * S , long Ea ) { pari_sp av = avma ; GEN beta = FpXQ_powu ( S -> nu , Ea , S -> chi , S -> p ) ; long N = degpol ( S -> f ) , v = varn ( S -> f ) ; S -> invnu = NULL ; for ( ; ; ) { long L , i , Fg , eq , er ; GEN chig = NULL , d , g , nug ; if ( DEBUGLEVEL > 4 ) err_printf ( " \n " , beta ) ; L = ZpX_resultant_val ( S -> chi , beta , S -> p , S -> mf + 1 ) ; if ( L > S -> mf ) L = -1 ; g = get_g ( S , Ea , L , N , beta , & chig , & eq , & er ) ; if ( DEBUGLEVEL > 4 ) err_printf ( " \n " , eq , er ) ; if ( split_char ( S , chig , g , S -> phi , & nug ) ) return 1 ; Fg = degpol ( nug ) ; if ( Fg == 1 ) { long Le , Ee ; GEN chie , nue , e , pie ; d = negi ( gel ( nug , 2 ) ) ; chie = RgX_translate ( chig , d ) ; nue = pol_x ( v ) ; e = RgX_Rg_sub ( g , d ) ; pie = getprime ( S , e , chie , nue , & Le , & Ee , 0 , Ea ) ; if ( pie ) return testc2 ( S , S -> nu , Ea , pie , Ee ) ; } else { long Fa = degpol ( S -> nu ) , vdeng ; GEN deng , numg , nume ; if ( Fa % Fg ) return testb2 ( S , ulcm ( Fa , Fg ) , g ) ; if ( ZX_equal ( nug , S -> nu ) ) d = pol_x ( v ) ; else { if ( ! p_is_prime ( S ) ) pari_err_PRIME ( " " , S -> p ) ; d = FpX_ffisom ( nug , S -> nu , S -> p ) ; } numg = QpX_remove_denom ( g , S -> p , & deng , & vdeng ) ; for ( i = 1 ; i <= Fg ; i ++ ) { GEN chie , nue , e ; if ( i != 1 ) d = FpXQ_pow ( d , S -> p , S -> nu , S -> p ) ; nume = ZX_sub ( numg , ZX_Z_mul ( d , deng ) ) ; if ( ZpX_resultant_val ( S -> chi , nume , S -> p , vdeng * N + 1 ) <= vdeng * N ) continue ; e = RgX_Rg_div ( nume , deng ) ; chie = mycaract ( S , S -> chi , e , S -> psc , S -> prc ) ; if ( split_char ( S , chie , e , S -> phi , & nue ) ) return 1 ; if ( RgX_is_monomial ( nue ) ) { long Le , Ee ; GEN pie ; pie = getprime ( S , e , chie , nue , & Le , & Ee , 0 , Ea ) ; if ( pie ) return testc2 ( S , S -> nu , Ea , pie , Ee ) ; break ; } } if ( i > Fg ) { if ( ! p_is_prime ( S ) ) pari_err_PRIME ( " " , S -> p ) ; pari_err_BUG ( " " ) ; } } if ( eq ) d = gmul ( d , powiu ( S -> p , eq ) ) ; if ( er ) d = gmul ( d , gpowgs ( S -> nu , er ) ) ; beta = gsub ( beta , d ) ; if ( gc_needed ( av , 1 ) ) { if ( DEBUGMEM > 1 ) pari_warn ( warnmem , " " ) ; gerepileall ( av , S -> invnu ? 6 : 4 , & beta , & ( S -> precns ) , & ( S -> ns ) , & ( S -> nsf ) , & ( S -> invnu ) , & ( S -> Dinvnu ) ) ; } } }
return 1 if at least 2 factors mod p ==> chi can be split
return 1 if at least 2 factors mod p == > chi can be split
/* beta tends to a factor of chi */ /* from scratch */ /* g = beta p^-eq  nu^-er (a unit), chig = charpoly(g) */ /* frequent special case nug = x - d */ /* nu & nug irreducible mod p, deg nug | deg nu. To improve beta, look
       * for a root d of nug in Fp[phi] such that v_p(g - d) > 0 */ /* write g = numg / deng, e = nume / deng */ /* next root */ /* test e = nume / deng */ /* v_p(e) = v_p(g - d) > 0 */