bridge/class-master/depend/pari/src/basemath/nffactor.c
/* return the factorization of x in nf */
return the factorization of x in nf
return the factorization of x in nf
GEN
nffactor(GEN nf,GEN pol)
{
  GEN bad, A, B, y, T, den, rep = cgetg(3, t_MAT);
  pari_sp av = avma;
  long dA;
  pari_timer ti;
  if (DEBUGLEVEL>2) { timer_start(&ti); err_printf("\nEntering nffactor:\n"); }
  T = get_nfpol(nf, &nf);
  RgX_check_ZX(T,"nffactor");
  A = RgX_nffix("nffactor",T,pol,1);
  dA = degpol(A);
  if (dA <= 0) {
    avma = (pari_sp)(rep + 3);
    return (dA == 0)? trivial_fact(): zerofact(varn(pol));
  }
  if (dA == 1) {
    GEN c;
    A = Q_primpart( QXQX_normalize(A, T) );
    A = gerepilecopy(av, A); c = gel(A,2);
    if (typ(c) == t_POL && degpol(c) > 0) gel(A,2) = mkpolmod(c, ZX_copy(T));
    gel(rep,1) = mkcol(A);
    gel(rep,2) = mkcol(gen_1); return rep;
  }
  if (degpol(T) == 1) return gerepileupto(av, QX_factor(simplify_shallow(A)));
  den = get_nfsqff_data(&nf, &T, &A, &B, &bad);
  if (DEBUGLEVEL>2) timer_printf(&ti, "squarefree test");
  if (RgX_is_ZX(B))
  {
    GEN v = gel(ZX_factor(B), 1);
    long i, l = lg(v);
    y = cgetg(1, t_VEC);
    for (i = 1; i < l; i++)
    {
      GEN b = gel(v,i); 
      y = shallowconcat(y, nfsqff(nf, b, 0, den));
    }
  }
  else
    y = nfsqff(nf,B, 0, den);
  if (DEBUGLEVEL>3) err_printf("number of factor(s) found: %ld\n", lg(y)-1);
  fact_from_sqff(rep, A, B, y, T, bad);
  return sort_factor_pol(rep, cmp_RgX);
}
GEN nffactor ( GEN nf , GEN pol ) { GEN bad , A , B , y , T , den , rep = cgetg ( 3 , t_MAT ) ; pari_sp av = avma ; long dA ; pari_timer ti ; if ( DEBUGLEVEL > 2 ) { timer_start ( & ti ) ; err_printf ( " \n \n " ) ; } T = get_nfpol ( nf , & nf ) ; RgX_check_ZX ( T , " " ) ; A = RgX_nffix ( " " , T , pol , 1 ) ; dA = degpol ( A ) ; if ( dA <= 0 ) { avma = ( pari_sp ) ( rep + 3 ) ; return ( dA == 0 ) ? trivial_fact ( ) : zerofact ( varn ( pol ) ) ; } if ( dA == 1 ) { GEN c ; A = Q_primpart ( QXQX_normalize ( A , T ) ) ; A = gerepilecopy ( av , A ) ; c = gel ( A , 2 ) ; if ( typ ( c ) == t_POL && degpol ( c ) > 0 ) gel ( A , 2 ) = mkpolmod ( c , ZX_copy ( T ) ) ; gel ( rep , 1 ) = mkcol ( A ) ; gel ( rep , 2 ) = mkcol ( gen_1 ) ; return rep ; } if ( degpol ( T ) == 1 ) return gerepileupto ( av , QX_factor ( simplify_shallow ( A ) ) ) ; den = get_nfsqff_data ( & nf , & T , & A , & B , & bad ) ; if ( DEBUGLEVEL > 2 ) timer_printf ( & ti , " " ) ; if ( RgX_is_ZX ( B ) ) { GEN v = gel ( ZX_factor ( B ) , 1 ) ; long i , l = lg ( v ) ; y = cgetg ( 1 , t_VEC ) ; for ( i = 1 ; i < l ; i ++ ) { GEN b = gel ( v , i ) ; y = shallowconcat ( y , nfsqff ( nf , b , 0 , den ) ) ; } } else y = nfsqff ( nf , B , 0 , den ) ; if ( DEBUGLEVEL > 3 ) err_printf ( " \n " , lg ( y ) - 1 ) ; fact_from_sqff ( rep , A , B , y , T , bad ) ; return sort_factor_pol ( rep , cmp_RgX ) ; }
return the factorization of x in nf
return the factorization of x in nf
/* irreducible / Q */