bridge/class-master/depend/pari/src/basemath/QX_factor.c
/* Checks if f, monic squarefree ZX with |constant coeff| = 1, is a cyclotomic
 * polynomial. Returns n if f = Phi_n, and 0 otherwise */
Checks if f, monic squarefree ZX with |constant coeff| = 1, is a cyclotomic
polynomial. Returns n if f = Phi_n, and 0 otherwise
Checks if f monic squarefree ZX with |constant coeff| = 1 is a cyclotomic polynomial . Returns n if f = Phi_n and 0 otherwise
static long
BD_iscyclo(GEN f)
{
  pari_sp av = avma;
  GEN f2, fn, f1;
  if (degpol(f) == 1) return isint1(gel(f,2))? 2: 1;
  f1 = ZX_graeffe(f);
  if (ZX_equal(f, f1)) { avma = av; return BD_odd_iscyclo(f); }
  fn = ZX_z_unscale(f, -1); 
  if (ZX_equal(f1, fn)) return 2*BD_odd_iscyclo(fn);
  if (issquareall(f1, &f2))
  {
    GEN lt = leading_coeff(f2);
    long c;
    if (signe(lt) < 0) f2 = ZX_neg(f2);
    c = BD_iscyclo(f2);
    return odd(c)? 0: 2*c;
  }
  avma = av; return 0;
}
static long BD_iscyclo ( GEN f ) { pari_sp av = avma ; GEN f2 , fn , f1 ; if ( degpol ( f ) == 1 ) return isint1 ( gel ( f , 2 ) ) ? 2 : 1 ; f1 = ZX_graeffe ( f ) ; if ( ZX_equal ( f , f1 ) ) { avma = av ; return BD_odd_iscyclo ( f ) ; } fn = ZX_z_unscale ( f , -1 ) ; if ( ZX_equal ( f1 , fn ) ) return 2 * BD_odd_iscyclo ( fn ) ; if ( issquareall ( f1 , & f2 ) ) { GEN lt = leading_coeff ( f2 ) ; long c ; if ( signe ( lt ) < 0 ) f2 = ZX_neg ( f2 ) ; c = BD_iscyclo ( f2 ) ; return odd ( c ) ? 0 : 2 * c ; } avma = av ; return 0 ; }
Checks if f, monic squarefree ZX with |constant coeff| = 1, is a cyclotomic
 polynomial.
Checks if f monic squarefree ZX with |constant coeff| = 1 is a cyclotomic polynomial .
/* f = product of Phi_n, n odd */ /* f(-x) */ /* f = product of Phi_n, n = 2 mod 4 */