bridge/class-master/depend/pari/src/basemath/FpX_factor.c
/* returns a root of unity in F_p that is suitable for finding a factor   */
/* of degree deg_factor of a polynomial of degree deg; the order is       */
/* returned in n                                                          */
/* A good choice seems to be n close to deg/deg_factor; we choose n       */
/* twice as big and decrement until it divides p-1.                       */
returns a root of unity in F_p that is suitable for finding a factor
of degree deg_factor of a polynomial of degree deg; the order is
returned in n
A good choice seems to be n close to deg/deg_factor; we choose n
twice as big and decrement until it divides p-1.
returns a root of unity in F_p that is suitable for finding a factor of degree deg_factor of a polynomial of degree deg ; the order is returned in n A good choice seems to be n close to deg / deg_factor ; we choose n twice as big and decrement until it divides p - 1 .
static GEN
good_root_of_unity(GEN p, long deg, long deg_factor, long *pt_n)
{
   pari_sp ltop = avma;
   GEN pm, factn, power, base, zeta;
   long n;
   pm = subis (p, 1ul);
   for (n = deg / 2 / deg_factor + 1; !dvdiu (pm, n); n--);
   factn = Z_factor(stoi(n));
   power = diviuexact (pm, n);
   base = gen_1;
   do {
      base = addis (base, 1l);
      zeta = Fp_pow (base, power, p);
   }
   while (!equaliu (Fp_order (zeta, factn, p), n));
   *pt_n = n;
   return gerepileuptoint (ltop, zeta);
}
static GEN good_root_of_unity ( GEN p , long deg , long deg_factor , long * pt_n ) { pari_sp ltop = avma ; GEN pm , factn , power , base , zeta ; long n ; pm = subis ( p , 1ul ) ; for ( n = deg / 2 / deg_factor + 1 ; ! dvdiu ( pm , n ) ; n -- ) ; factn = Z_factor ( stoi ( n ) ) ; power = diviuexact ( pm , n ) ; base = gen_1 ; do { base = addis ( base , 1l ) ; zeta = Fp_pow ( base , power , p ) ; } while ( ! equaliu ( Fp_order ( zeta , factn , p ) , n ) ) ; * pt_n = n ; return gerepileuptoint ( ltop , zeta ) ; }
returns a root of unity in F_p that is suitable for finding a factor
of degree deg_factor of a polynomial of degree deg; the order is
returned in n
A good choice seems to be n close to deg/deg_factor; we choose n
twice as big and decrement until it divides p-1.
returns a root of unity in F_p that is suitable for finding a factor of degree deg_factor of a polynomial of degree deg ; the order is returned in n A good choice seems to be n close to deg / deg_factor ; we choose n twice as big and decrement until it divides p - 1 .