bridge/class-master/depend/pari/src/basemath/ifactor1.c
/* find primary factors of n; destroy n */
find primary factors of n; destroy n
find primary factors of n ; destroy n
static long
ifac_decomp(GEN n, long hint)
{
  pari_sp av = avma;
  long nb = 0;
  GEN part, here, workspc, pairs = (GEN)av;
  workspc = new_chunk((expi(n) + 1) * 7);
  part = ifac_start_hint(n, 0, hint);
  for (;;)
  {
    here = ifac_main(&part);
    if (!here) break;
    if (gc_needed(av,1))
    {
      long offset;
      if(DEBUGMEM>1)
      {
        pari_warn(warnmem,"[2] ifac_decomp");
        ifac_print(part, here);
      }
      ifac_realloc(&part, &here, 0);
      offset = here - part;
      part = gerepileupto((pari_sp)workspc, part);
      here = part + offset;
    }
    nb++;
    pairs = icopy_avma(VALUE(here), (pari_sp)pairs);
    pairs = icopy_avma(EXPON(here), (pari_sp)pairs);
    ifac_delete(here);
  }
  avma = (pari_sp)pairs;
  if (DEBUGLEVEL >= 3)
    err_printf("IFAC: found %ld large prime (power) factor%s.\n",
               nb, (nb>1? "s": ""));
  return nb;
}
static long ifac_decomp ( GEN n , long hint ) { pari_sp av = avma ; long nb = 0 ; GEN part , here , workspc , pairs = ( GEN ) av ; workspc = new_chunk ( ( expi ( n ) + 1 ) * 7 ) ; part = ifac_start_hint ( n , 0 , hint ) ; for ( ; ; ) { here = ifac_main ( & part ) ; if ( ! here ) break ; if ( gc_needed ( av , 1 ) ) { long offset ; if ( DEBUGMEM > 1 ) { pari_warn ( warnmem , " " ) ; ifac_print ( part , here ) ; } ifac_realloc ( & part , & here , 0 ) ; offset = here - part ; part = gerepileupto ( ( pari_sp ) workspc , part ) ; here = part + offset ; } nb ++ ; pairs = icopy_avma ( VALUE ( here ) , ( pari_sp ) pairs ) ; pairs = icopy_avma ( EXPON ( here ) , ( pari_sp ) pairs ) ; ifac_delete ( here ) ; } avma = ( pari_sp ) pairs ; if ( DEBUGLEVEL >= 3 ) err_printf ( " \n " , nb , ( nb > 1 ? " " : " " ) ) ; return nb ; }
find primary factors of n; destroy n
find primary factors of n ; destroy n
/* workspc will be doled out in pairs of smaller t_INTs. For n = prod p^{e_p}
   * (p not necessarily prime), need room to store all p and e_p [ cgeti(3) ],
   * bounded by
   *    sum_{p | n} ( log_{2^BIL} (p) + 6 ) <= log_{2^BIL} n + 6 log_2 n */