bridge/class-master/depend/pari/src/basemath/nffactor.c
/* if *pnf = NULL replace if by a "quick" K = nfinit(T), ensuring maximality
 * by small primes only. Return a multiplicative bound for the denominator of
 * algebraic integers in Z_K in terms of K.zk */
if *pnf = NULL replace if by a "quick" K = nfinit(T), ensuring maximality
by small primes only. Return a multiplicative bound for the denominator of
algebraic integers in Z_K in terms of K.zk
if * pnf = NULL replace if by a " quick " K = nfinit ( T ) ensuring maximality by small primes only . Return a multiplicative bound for the denominator of algebraic integers in Z_K in terms of K . zk
static GEN
fix_nf(GEN *pnf, GEN *pT, GEN *pA)
{
  GEN nf, NF, fa, P, Q, q, D, T = *pT;
  nfmaxord_t S;
  long i, l;
  if (*pnf) return gen_1;
  nfmaxord(&S, T, nf_PARTIALFACT);
  NF = nfinit_complete(&S, 0, DEFAULTPREC);
  *pnf = nf = proper_nf(NF);
  if (nf != NF) { 
    GEN A = *pA, a = cgetg_copy(A, &l);
    GEN rev = gel(NF,2), pow, dpow;
    *pT = T = nf_get_pol(nf); 
    pow = QXQ_powers(lift_shallow(rev), degpol(T)-1, T);
    pow = Q_remove_denom(pow, &dpow);
    a[1] = A[1];
    for (i=2; i<l; i++) {
      GEN c = gel(A,i);
      if (typ(c) == t_POL) c = QX_ZXQV_eval(c, pow, dpow);
      gel(a,i) = c;
    }
    *pA = Q_primpart(a); 
  }
  D = nf_get_disc(nf);
  if (is_pm1(D)) return gen_1;
  fa = absZ_factor_limit(D, 0);
  P = gel(fa,1); q = gel(P, lg(P)-1);
  if (BPSW_psp(q)) return gen_1;
  P = nf_get_ramified_primes(nf);
  l = lg(P);
  Q = q; q = gen_1;
  for (i = 1; i < l; i++)
  {
    GEN p = gel(P,i);
    if (Z_pvalrem(Q, p, &Q) && !BPSW_psp(p)) q = mulii(q, p);
  }
  return q;
}
static GEN fix_nf ( GEN * pnf , GEN * pT , GEN * pA ) { GEN nf , NF , fa , P , Q , q , D , T = * pT ; nfmaxord_t S ; long i , l ; if ( * pnf ) return gen_1 ; nfmaxord ( & S , T , nf_PARTIALFACT ) ; NF = nfinit_complete ( & S , 0 , DEFAULTPREC ) ; * pnf = nf = proper_nf ( NF ) ; if ( nf != NF ) { GEN A = * pA , a = cgetg_copy ( A , & l ) ; GEN rev = gel ( NF , 2 ) , pow , dpow ; * pT = T = nf_get_pol ( nf ) ; pow = QXQ_powers ( lift_shallow ( rev ) , degpol ( T ) - 1 , T ) ; pow = Q_remove_denom ( pow , & dpow ) ; a [ 1 ] = A [ 1 ] ; for ( i = 2 ; i < l ; i ++ ) { GEN c = gel ( A , i ) ; if ( typ ( c ) == t_POL ) c = QX_ZXQV_eval ( c , pow , dpow ) ; gel ( a , i ) = c ; } * pA = Q_primpart ( a ) ; } D = nf_get_disc ( nf ) ; if ( is_pm1 ( D ) ) return gen_1 ; fa = absZ_factor_limit ( D , 0 ) ; P = gel ( fa , 1 ) ; q = gel ( P , lg ( P ) - 1 ) ; if ( BPSW_psp ( q ) ) return gen_1 ; P = nf_get_ramified_primes ( nf ) ; l = lg ( P ) ; Q = q ; q = gen_1 ; for ( i = 1 ; i < l ; i ++ ) { GEN p = gel ( P , i ) ; if ( Z_pvalrem ( Q , p , & Q ) && ! BPSW_psp ( p ) ) q = mulii ( q , p ) ; } return q ; }
if *pnf = NULL replace if by a "quick" K = nfinit(T), ensuring maximality
 by small primes only.
if * pnf = NULL replace if by a " quick " K = nfinit ( T ) ensuring maximality by small primes only .
/* t_POL defining base field changed (not monic) */ /* need to update T */ /* need to update A */ /* nf_get_disc(nf) may be incorrect */