bridge/class-master/depend/pari/src/basemath/nffactor.c
/* return the roots of pol in nf */
return the roots of pol in nf
return the roots of pol in nf
GEN
nfroots(GEN nf,GEN pol)
{
  pari_sp av = avma;
  GEN z, A, B, T, den;
  long d, dT;
  if (!nf) return nfrootsQ(pol);
  T = get_nfpol(nf, &nf);
  RgX_check_ZX(T,"nfroots");
  A = RgX_nffix("nfroots", T,pol,1);
  d = degpol(A);
  if (d < 0) pari_err_ROOTS0("nfroots");
  if (d == 0) return cgetg(1,t_VEC);
  if (d == 1)
  {
    A = QXQX_normalize(A,T);
    A = mkpolmod(gneg_i(gel(A,2)), T);
    return gerepilecopy(av, mkvec(A));
  }
  dT = degpol(T);
  if (dT == 1) return gerepileupto(av, nfrootsQ(simplify_shallow(A)));
  den = get_nfsqff_data(&nf, &T, &A, &B, NULL);
  if (RgX_is_ZX(B))
  {
    GEN v = gel(ZX_factor(B), 1);
    long i, l = lg(v), p = mael(factoru(dT),1,1); 
    z = cgetg(1, t_VEC);
    for (i = 1; i < l; i++)
    {
      GEN b = gel(v,i); 
      long db = degpol(b);
      if (db != 1 && degpol(b) < p) continue;
      z = shallowconcat(z, nfsqff(nf, b, ROOTS, den));
    }
  }
  else
    z = nfsqff(nf,B, ROOTS, den);
  z = gerepileupto(av, QXQV_to_mod(z, T));
  gen_sort_inplace(z, (void*)&cmp_RgX, &cmp_nodata, NULL);
  return z;
}
GEN nfroots ( GEN nf , GEN pol ) { pari_sp av = avma ; GEN z , A , B , T , den ; long d , dT ; if ( ! nf ) return nfrootsQ ( pol ) ; T = get_nfpol ( nf , & nf ) ; RgX_check_ZX ( T , " " ) ; A = RgX_nffix ( " " , T , pol , 1 ) ; d = degpol ( A ) ; if ( d < 0 ) pari_err_ROOTS0 ( " " ) ; if ( d == 0 ) return cgetg ( 1 , t_VEC ) ; if ( d == 1 ) { A = QXQX_normalize ( A , T ) ; A = mkpolmod ( gneg_i ( gel ( A , 2 ) ) , T ) ; return gerepilecopy ( av , mkvec ( A ) ) ; } dT = degpol ( T ) ; if ( dT == 1 ) return gerepileupto ( av , nfrootsQ ( simplify_shallow ( A ) ) ) ; den = get_nfsqff_data ( & nf , & T , & A , & B , NULL ) ; if ( RgX_is_ZX ( B ) ) { GEN v = gel ( ZX_factor ( B ) , 1 ) ; long i , l = lg ( v ) , p = mael ( factoru ( dT ) , 1 , 1 ) ; z = cgetg ( 1 , t_VEC ) ; for ( i = 1 ; i < l ; i ++ ) { GEN b = gel ( v , i ) ; long db = degpol ( b ) ; if ( db != 1 && degpol ( b ) < p ) continue ; z = shallowconcat ( z , nfsqff ( nf , b , ROOTS , den ) ) ; } } else z = nfsqff ( nf , B , ROOTS , den ) ; z = gerepileupto ( av , QXQV_to_mod ( z , T ) ) ; gen_sort_inplace ( z , ( void * ) & cmp_RgX , & cmp_nodata , NULL ) ; return z ; }
return the roots of pol in nf
return the roots of pol in nf
/* smallest prime divisor */ /* irreducible / Q */