bridge/class-master/depend/pari/src/basemath/mftrace.c
/* table of 6 * Hurwitz class numbers D <= lim */
table of 6 * Hurwitz class numbers D <= lim
table of 6 * Hurwitz class numbers D < = lim
static void
consttabh(long lim)
{
  pari_sp av = avma, av2;
  GEN VHDH0, VDIV, CACHE = NULL;
  GEN VHDH = caches[cache_H].cache;
  long r, N, cachea, cacheb, lim0 = VHDH? lg(VHDH)-1: 2, LIM = lim0 << 1;
  if (lim <= 0) lim = 5;
  if (lim <= LIM) return;
  cache_reset(cache_H);
  r = lim&3L; if (r) lim += 4-r;
  cache_get(cache_DIV, lim);
  VDIV = caches[cache_DIV].cache;
  VHDH0 = cgetg(lim/2 + 1, t_VECSMALL);
  VHDH0[1] = 2;
  VHDH0[2] = 3;
  for (N = 3; N <= lim0; N++) VHDH0[N] = VHDH[N];
  av2 = avma;
  cachea = cacheb = 0;
  for (N = LIM + 3; N <= lim; N += 4)
  {
    long s = 0, limt = usqrt(N>>2), flsq = 0, ind, t, L, S;
    GEN DN, DN2;
    if (N + 2 >= lg(VDIV))
    { 
      GEN F;
      if (N + 2 > cacheb)
      {
        avma = av2; cachea = N;
        CACHE = update_factor_cache(N, lim+2, &cacheb);
      }
      F = gel(CACHE, ((N-cachea)>>1)+1); 
      DN = divisorsu_fact(F);
      F = gel(CACHE, ((N-cachea)>>1)+2); 
      DN2 = divisorsu_fact(F);
    }
    else
    { 
      DN = gel(VDIV,N);
      DN2 = gel(VDIV,N+2);
    }
    ind = N >> 1;
    for (t = 1; t <= limt; t++)
    {
      ind -= (t<<2)-2; 
      if (ind) s += VHDH0[ind]; else flsq = 1;
    }
    lamsig(DN, &L,&S);
    VHDH0[N >> 1] = 2*S - 3*L - 2*s + flsq;
    s = 0; flsq = 0; limt = (usqrt(N+2) - 1) >> 1;
    ind = (N+1) >> 1;
    for (t = 1; t <= limt; t++)
    {
      ind -= t<<2; 
      if (ind) s += VHDH0[ind]; else flsq = 1;
    }
    lamsig(DN2, &L,&S);
    VHDH0[(N+1) >> 1] = S - 3*(L >> 1) - s - flsq;
  }
  cache_set(cache_H, VHDH0); avma = av;
}
static void consttabh ( long lim ) { pari_sp av = avma , av2 ; GEN VHDH0 , VDIV , CACHE = NULL ; GEN VHDH = caches [ cache_H ] . cache ; long r , N , cachea , cacheb , lim0 = VHDH ? lg ( VHDH ) - 1 : 2 , LIM = lim0 << 1 ; if ( lim <= 0 ) lim = 5 ; if ( lim <= LIM ) return ; cache_reset ( cache_H ) ; r = lim & 3L ; if ( r ) lim += 4 - r ; cache_get ( cache_DIV , lim ) ; VDIV = caches [ cache_DIV ] . cache ; VHDH0 = cgetg ( lim / 2 + 1 , t_VECSMALL ) ; VHDH0 [ 1 ] = 2 ; VHDH0 [ 2 ] = 3 ; for ( N = 3 ; N <= lim0 ; N ++ ) VHDH0 [ N ] = VHDH [ N ] ; av2 = avma ; cachea = cacheb = 0 ; for ( N = LIM + 3 ; N <= lim ; N += 4 ) { long s = 0 , limt = usqrt ( N >> 2 ) , flsq = 0 , ind , t , L , S ; GEN DN , DN2 ; if ( N + 2 >= lg ( VDIV ) ) { GEN F ; if ( N + 2 > cacheb ) { avma = av2 ; cachea = N ; CACHE = update_factor_cache ( N , lim + 2 , & cacheb ) ; } F = gel ( CACHE , ( ( N - cachea ) >> 1 ) + 1 ) ; DN = divisorsu_fact ( F ) ; F = gel ( CACHE , ( ( N - cachea ) >> 1 ) + 2 ) ; DN2 = divisorsu_fact ( F ) ; } else { DN = gel ( VDIV , N ) ; DN2 = gel ( VDIV , N + 2 ) ; } ind = N >> 1 ; for ( t = 1 ; t <= limt ; t ++ ) { ind -= ( t << 2 ) - 2 ; if ( ind ) s += VHDH0 [ ind ] ; else flsq = 1 ; } lamsig ( DN , & L , & S ) ; VHDH0 [ N >> 1 ] = 2 * S - 3 * L - 2 * s + flsq ; s = 0 ; flsq = 0 ; limt = ( usqrt ( N + 2 ) - 1 ) >> 1 ; ind = ( N + 1 ) >> 1 ; for ( t = 1 ; t <= limt ; t ++ ) { ind -= t << 2 ; if ( ind ) s += VHDH0 [ ind ] ; else flsq = 1 ; } lamsig ( DN2 , & L , & S ) ; VHDH0 [ ( N + 1 ) >> 1 ] = S - 3 * ( L >> 1 ) - s - flsq ; } cache_set ( cache_H , VHDH0 ) ; avma = av ; }
table of 6 * Hurwitz class numbers D <= lim
table of 6 * Hurwitz class numbers D < = lim
/* use local cache */ /* factoru(N) */ /* factoru(N+2) */ /* use global cache */ /* N/2 - 2t^2 */ /* (N+1)/2 - 2t(t+1) */