bridge/class-master/depend/pari/src/basemath/galconj.c
/* Heuristic computation of #Aut(T), pinit = first prime to be tested */
Heuristic computation of #Aut(T), pinit = first prime to be tested
Heuristic computation of #Aut ( T ) pinit = first prime to be tested
long
numberofconjugates(GEN T, long pinit)
{
  pari_sp av = avma;
  long c, nbtest, nbmax, n = degpol(T);
  ulong p;
  forprime_t S;
  if (n == 1) return 1;
  nbmax = (n < 10)? 20: (n<<1) + 1;
  nbtest = 0;
#if 0
  c = ZX_sturm(T); c = ugcd(c, n-c); 
#else
  c = n;
#endif
  u_forprime_init(&S, pinit, ULONG_MAX);
  while((p = u_forprime_next(&S)))
  {
    GEN L, Tp = ZX_to_Flx(T,p);
    long i, nb;
    if (!Flx_is_squarefree(Tp, p)) continue;
    nbtest++;
    L = Flx_nbfact_by_degree(Tp, &nb, p); 
    if (L[n/nb] == nb) {
      if (c == n && nbtest > 10) break; 
    }
    else
    {
      c = ugcd(c, L[1]);
      for (i = 2; i <= n; i++)
        if (L[i]) { c = ugcd(c, L[i]*i); if (c == 1) break; }
      if (c == 1) break;
    }
    if (nbtest == nbmax) break;
    if (DEBUGLEVEL >= 6)
      err_printf("NumberOfConjugates [%ld]:c=%ld,p=%ld\n", nbtest,c,p);
    avma = av;
  }
  if (DEBUGLEVEL >= 2) err_printf("NumberOfConjugates:c=%ld,p=%ld\n", c, p);
  avma = av; return c;
}
long numberofconjugates ( GEN T , long pinit ) { pari_sp av = avma ; long c , nbtest , nbmax , n = degpol ( T ) ; ulong p ; forprime_t S ; if ( n == 1 ) return 1 ; nbmax = ( n < 10 ) ? 20 : ( n << 1 ) + 1 ; nbtest = 0 ; #if 0 c = ZX_sturm ( T ) ; c = ugcd ( c , n - c ) ; #else c = n ; #endif u_forprime_init ( & S , pinit , ULONG_MAX ) ; while ( ( p = u_forprime_next ( & S ) ) ) { GEN L , Tp = ZX_to_Flx ( T , p ) ; long i , nb ; if ( ! Flx_is_squarefree ( Tp , p ) ) continue ; nbtest ++ ; L = Flx_nbfact_by_degree ( Tp , & nb , p ) ; if ( L [ n / nb ] == nb ) { if ( c == n && nbtest > 10 ) break ; } else { c = ugcd ( c , L [ 1 ] ) ; for ( i = 2 ; i <= n ; i ++ ) if ( L [ i ] ) { c = ugcd ( c , L [ i ] * i ) ; if ( c == 1 ) break ; } if ( c == 1 ) break ; } if ( nbtest == nbmax ) break ; if ( DEBUGLEVEL >= 6 ) err_printf ( " \n " , nbtest , c , p ) ; avma = av ; } if ( DEBUGLEVEL >= 2 ) err_printf ( " \n " , c , p ) ; avma = av ; return c ; }
Heuristic computation of #Aut(T), pinit = first prime to be tested
Heuristic computation of #Aut ( T ) pinit = first prime to be tested
/* too costly: finite primes are cheaper */ /* unramified */ /* L[i] = #factors of degree i */ /* probably Galois */