bridge/class-master/depend/pari/src/basemath/ifactor1.c
/* Divide all current composites by first (prime, class Q) entry, updating its
 * exponent, and turning it into a finished prime (class P).  Return 1 if any
 * such divisions succeeded  (in Moebius mode, the update may then not have
 * been completed), or 0 if none of them succeeded.  Doesn't modify *where.
 * Here we normally do not check that the first entry is a not-finished
 * prime.  Stack management: we may allocate a new exponent */
Divide all current composites by first (prime, class Q) entry, updating its
exponent, and turning it into a finished prime (class P).  Return 1 if any
such divisions succeeded  (in Moebius mode, the update may then not have
been completed), or 0 if none of them succeeded.  Doesn't modify *where.
Here we normally do not check that the first entry is a not-finished
prime.  Stack management: we may allocate a new exponent
Divide all current composites by first ( prime class Q ) entry updating its exponent and turning it into a finished prime ( class P ) . Return 1 if any such divisions succeeded ( in Moebius mode the update may then not have been completed ) or 0 if none of them succeeded . Doesn ' t modify * where . Here we normally do not check that the first entry is a not - finished prime . Stack management : we may allocate a new exponent
static long
ifac_divide(GEN *partial, GEN *where, long moebius_mode)
{
  GEN scan, scan_end = LAST(*partial);
  long res = 0, exponent, newexp, otherexp;
#ifdef IFAC_DEBUG
  ifac_check(*partial, *where);
  if (CLASS(*where) != gen_1)
    pari_err_BUG("ifac_divide [division by composite or finished prime]");
  if (!VALUE(*where)) pari_err_BUG("ifac_divide [division by nothing]");
#endif
  newexp = exponent = itos(EXPON(*where));
  if (exponent > 1 && moebius_mode) return 1;
  for (scan = *where+3; scan <= scan_end; scan += 3)
  {
    if (CLASS(scan) != gen_0) continue; 
    otherexp = 0;
    while (dvdiiz(VALUE(scan), VALUE(*where), VALUE(scan)))
    {
      if (moebius_mode) return 1; 
      if (!otherexp) otherexp = itos(EXPON(scan));
      newexp += otherexp;
    }
    if (newexp > exponent)        
    {
      EXPON(*where) = (newexp == 2 ? gen_2 : utoipos(newexp));
      exponent = newexp;
      if (is_pm1((GEN)*scan)) 
      {
        ifac_delete(scan);
        if (DEBUGLEVEL >= 4)
          err_printf("IFAC: a factor was a power of another prime factor\n");
      } else {
        CLASS(scan) = NULL;        
        if (DEBUGLEVEL >= 4)
          err_printf("IFAC: a factor was divisible by another prime factor,\n"
                     "\tleaving a cofactor = %Ps\n", VALUE(scan));
      }
      res = 1;
      if (DEBUGLEVEL >= 5)
        err_printf("IFAC: prime %Ps\n\tappears at least to the power %ld\n",
                   VALUE(*where), newexp);
    }
  } 
  CLASS(*where) = gen_2; 
  if (DEBUGLEVEL >= 3)
    err_printf("IFAC: prime %Ps\n\tappears with exponent = %ld\n",
               VALUE(*where), newexp);
  return res;
}
static long ifac_divide ( GEN * partial , GEN * where , long moebius_mode ) { GEN scan , scan_end = LAST ( * partial ) ; long res = 0 , exponent , newexp , otherexp ; #ifdef IFAC_DEBUG ifac_check ( * partial , * where ) ; if ( CLASS ( * where ) != gen_1 ) pari_err_BUG ( " " ) ; if ( ! VALUE ( * where ) ) pari_err_BUG ( " " ) ; #endif newexp = exponent = itos ( EXPON ( * where ) ) ; if ( exponent > 1 && moebius_mode ) return 1 ; for ( scan = * where + 3 ; scan <= scan_end ; scan += 3 ) { if ( CLASS ( scan ) != gen_0 ) continue ; otherexp = 0 ; while ( dvdiiz ( VALUE ( scan ) , VALUE ( * where ) , VALUE ( scan ) ) ) { if ( moebius_mode ) return 1 ; if ( ! otherexp ) otherexp = itos ( EXPON ( scan ) ) ; newexp += otherexp ; } if ( newexp > exponent ) { EXPON ( * where ) = ( newexp == 2 ? gen_2 : utoipos ( newexp ) ) ; exponent = newexp ; if ( is_pm1 ( ( GEN ) * scan ) ) { ifac_delete ( scan ) ; if ( DEBUGLEVEL >= 4 ) err_printf ( " \n " ) ; } else { CLASS ( scan ) = NULL ; if ( DEBUGLEVEL >= 4 ) err_printf ( " \n " " \t \n " , VALUE ( scan ) ) ; } res = 1 ; if ( DEBUGLEVEL >= 5 ) err_printf ( " \n \t \n " , VALUE ( * where ) , newexp ) ; } } CLASS ( * where ) = gen_2 ; if ( DEBUGLEVEL >= 3 ) err_printf ( " \n \t \n " , VALUE ( * where ) , newexp ) ; return res ; }
Divide all current composites by first (prime, class Q) entry, updating its
 exponent, and turning it into a finished prime (class P).
Divide all current composites by first ( prime class Q ) entry updating its exponent and turning it into a finished prime ( class P ) .
/* should've been caught by caller */ /* the other thing ain't composite */ /* divide in place to keep stack clutter minimal */ /* immediately */ /* did anything happen? */ /* factor dissolved completely */ /* at any rate it's Unknown now */ /* for */ /* make it a finished prime */