bridge/class-master/depend/pari/src/basemath/trans3.c
/* compute the values of the twisted partial
   zeta function Z_f(a, c, s) for a in va */
compute the values of the twisted partial
zeta function Z_f(a, c, s) for a in va
compute the values of the twisted partial zeta function Z_f ( a c s ) for a in va
GEN
twistpartialzeta(GEN q, long f, long c, GEN va, GEN cff)
{
  long j, k, lva = lg(va)-1, N = lg(cff)-1;
  pari_sp av, av2;
  GEN Ax, Cx, Bx, Dx, x = pol_x(0), y = pol_x(1);
  GEN cyc, psm, rep, eta, etaf;
  cyc = gdiv(gsubgs(gpowgs(y, c), 1), gsubgs(y, 1));
  psm = polsym(cyc, degpol(cyc) - 1);
  eta = mkpolmod(y, cyc);
  etaf = gpowgs(eta,f);
  av = avma;
  Ax  = gsubgs(gpowgs(gaddgs(x, 1), f), 1);
  Ax  = gdiv(gmul(Ax, etaf), gsubsg(1, etaf));
  Ax  = gerepileupto(av, RgX_to_FqX(Ax, cyc, q));
  Cx  = Ax;
  Bx  = gen_1;
  av  = avma;
  for (j = 2; j <= N; j++)
  {
    Bx = gadd(Bx, Cx);
    Bx = FpXQX_red(Bx, cyc, q);
    Cx = FpXQX_mul(Cx, Ax, cyc, q);
    Cx = pol_mod_xn(Cx, N);
    if (gequal0(Cx)) break;
    if (gc_needed(av, 1))
    {
      if(DEBUGMEM>1) pari_warn(warnmem, "twistpartialzeta (1), j = %ld/%ld", j, N);
      gerepileall(av, 2, &Cx, &Bx);
    }
  }
  Bx  = lift_shallow(gmul(ginv(gsubsg(1, etaf)), Bx));
  Bx  = gerepileupto(av, RgX_to_FqX(Bx, cyc, q));
  Cx = lift_shallow(gmul(eta, gaddsg(1, x)));
  Dx = pol_1(varn(x));
  av2 = avma;
  for (j = lva; j > 1; j--)
  {
    GEN Ex;
    long e = va[j] - va[j-1];
    if (e == 1)
      Ex = Cx;
    else
      Ex = gpowgs(Cx, e);
    Dx = gaddsg(1, FpXQX_mul(Dx, Ex, cyc, q));
    if (gc_needed(av2, 1))
    {
      if(DEBUGMEM>1)
        pari_warn(warnmem, "twistpartialzeta (2), j = %ld/%ld", lva-j, lva);
      Dx = gerepileupto(av2, FpXQX_red(Dx, cyc, q));
    }
  }
  Dx = FpXQX_mul(Dx, Cx, cyc, q); 
  Bx = gerepileupto(av, FpXQX_mul(Dx, Bx, cyc, q));
  rep = gen_0;
  av2 = avma;
  for (k = 1; k <= N; k++)
  {
    GEN p2, ak = polcoef_i(Bx, k, 0);
    p2  = quicktrace(ak, psm);
    rep = modii(addii(rep, mulii(gel(cff, k), p2)), q);
    if (gc_needed(av2, 1))
    {
      if(DEBUGMEM>1) pari_warn(warnmem, "twistpartialzeta (3), j = %ld/%ld", k, N);
      rep = gerepileupto(av2, rep);
    }
  }
  return rep;
}
GEN twistpartialzeta ( GEN q , long f , long c , GEN va , GEN cff ) { long j , k , lva = lg ( va ) - 1 , N = lg ( cff ) - 1 ; pari_sp av , av2 ; GEN Ax , Cx , Bx , Dx , x = pol_x ( 0 ) , y = pol_x ( 1 ) ; GEN cyc , psm , rep , eta , etaf ; cyc = gdiv ( gsubgs ( gpowgs ( y , c ) , 1 ) , gsubgs ( y , 1 ) ) ; psm = polsym ( cyc , degpol ( cyc ) - 1 ) ; eta = mkpolmod ( y , cyc ) ; etaf = gpowgs ( eta , f ) ; av = avma ; Ax = gsubgs ( gpowgs ( gaddgs ( x , 1 ) , f ) , 1 ) ; Ax = gdiv ( gmul ( Ax , etaf ) , gsubsg ( 1 , etaf ) ) ; Ax = gerepileupto ( av , RgX_to_FqX ( Ax , cyc , q ) ) ; Cx = Ax ; Bx = gen_1 ; av = avma ; for ( j = 2 ; j <= N ; j ++ ) { Bx = gadd ( Bx , Cx ) ; Bx = FpXQX_red ( Bx , cyc , q ) ; Cx = FpXQX_mul ( Cx , Ax , cyc , q ) ; Cx = pol_mod_xn ( Cx , N ) ; if ( gequal0 ( Cx ) ) break ; if ( gc_needed ( av , 1 ) ) { if ( DEBUGMEM > 1 ) pari_warn ( warnmem , " " , j , N ) ; gerepileall ( av , 2 , & Cx , & Bx ) ; } } Bx = lift_shallow ( gmul ( ginv ( gsubsg ( 1 , etaf ) ) , Bx ) ) ; Bx = gerepileupto ( av , RgX_to_FqX ( Bx , cyc , q ) ) ; Cx = lift_shallow ( gmul ( eta , gaddsg ( 1 , x ) ) ) ; Dx = pol_1 ( varn ( x ) ) ; av2 = avma ; for ( j = lva ; j > 1 ; j -- ) { GEN Ex ; long e = va [ j ] - va [ j - 1 ] ; if ( e == 1 ) Ex = Cx ; else Ex = gpowgs ( Cx , e ) ; Dx = gaddsg ( 1 , FpXQX_mul ( Dx , Ex , cyc , q ) ) ; if ( gc_needed ( av2 , 1 ) ) { if ( DEBUGMEM > 1 ) pari_warn ( warnmem , " " , lva - j , lva ) ; Dx = gerepileupto ( av2 , FpXQX_red ( Dx , cyc , q ) ) ; } } Dx = FpXQX_mul ( Dx , Cx , cyc , q ) ; Bx = gerepileupto ( av , FpXQX_mul ( Dx , Bx , cyc , q ) ) ; rep = gen_0 ; av2 = avma ; for ( k = 1 ; k <= N ; k ++ ) { GEN p2 , ak = polcoef_i ( Bx , k , 0 ) ; p2 = quicktrace ( ak , psm ) ; rep = modii ( addii ( rep , mulii ( gel ( cff , k ) , p2 ) ) , q ) ; if ( gc_needed ( av2 , 1 ) ) { if ( DEBUGMEM > 1 ) pari_warn ( warnmem , " " , k , N ) ; rep = gerepileupto ( av2 , rep ) ; } } return rep ; }
compute the values of the twisted partial
zeta function Z_f(a, c, s) for a in va
compute the values of the twisted partial zeta function Z_f ( a c s ) for a in va
/* e is very small in general and actually very rarely different
         to 1, it is always 1 for zetap (so it should be OK not to store
         them or to compute them in a smart way) */ /* va[1] = 1 */