bridge/class-master/depend/pari/src/basemath/mftrace.c
/* CHI is a character defined modulo N4 */
CHI is a character defined modulo N4
CHI is a character defined modulo N4
static GEN
RgV_shimura(GEN V, long n, long D, long N4, long r, GEN CHI)
{
  GEN R, a0, Pn = mfcharpol(CHI);
  long m, Da, ND, ord = mfcharorder(CHI), vt = varn(Pn), d4 = D & 3L;
  if (d4 == 2 || d4 == 3) D *= 4;
  Da = labs(D); ND = N4*Da;
  R = cgetg(n + 2, t_VEC);
  a0 = gel(V, 1);
  if (!gequal0(a0))
  {
    long D4 = D << 2;
    GEN CHID = induceN(ulcm(mfcharmodulus(CHI), labs(D4)), CHI);
    CHID = mfcharmul_i(CHID, induce(gel(CHID,1), stoi(D4)));
    a0 = gmul(a0, charLFwtk(r, CHID, mfcharorder(CHID)));
  }
  if (odd(ND) && !odd(mfcharmodulus(CHI))) ND <<= 1;
  gel(R, 1) = a0;
  for (m = 1; m <= n; m++)
  {
    GEN Dm = mydivisorsu(u_ppo(m, ND)), S = gel(V, m*m + 1);
    long i, l = lg(Dm);
    for (i = 2; i < l; i++)
    { 
      long e = Dm[i], me = m / e;
      long a = mfcharevalord(CHI, e, ord);
      GEN c, C = powuu(e, r - 1);
      if (kross(D, e) == -1) C = negi(C);
      c = mygmodulo_lift(a, ord, C, vt);
      S = gadd(S, gmul(c, gel(V, me*me + 1)));
    }
    gel(R, m+1) = S;
  }
  return degpol(Pn) > 1? gmodulo(R, Pn): R;
}
static GEN RgV_shimura ( GEN V , long n , long D , long N4 , long r , GEN CHI ) { GEN R , a0 , Pn = mfcharpol ( CHI ) ; long m , Da , ND , ord = mfcharorder ( CHI ) , vt = varn ( Pn ) , d4 = D & 3L ; if ( d4 == 2 || d4 == 3 ) D *= 4 ; Da = labs ( D ) ; ND = N4 * Da ; R = cgetg ( n + 2 , t_VEC ) ; a0 = gel ( V , 1 ) ; if ( ! gequal0 ( a0 ) ) { long D4 = D << 2 ; GEN CHID = induceN ( ulcm ( mfcharmodulus ( CHI ) , labs ( D4 ) ) , CHI ) ; CHID = mfcharmul_i ( CHID , induce ( gel ( CHID , 1 ) , stoi ( D4 ) ) ) ; a0 = gmul ( a0 , charLFwtk ( r , CHID , mfcharorder ( CHID ) ) ) ; } if ( odd ( ND ) && ! odd ( mfcharmodulus ( CHI ) ) ) ND <<= 1 ; gel ( R , 1 ) = a0 ; for ( m = 1 ; m <= n ; m ++ ) { GEN Dm = mydivisorsu ( u_ppo ( m , ND ) ) , S = gel ( V , m * m + 1 ) ; long i , l = lg ( Dm ) ; for ( i = 2 ; i < l ; i ++ ) { long e = Dm [ i ] , me = m / e ; long a = mfcharevalord ( CHI , e , ord ) ; GEN c , C = powuu ( e , r - 1 ) ; if ( kross ( D , e ) == -1 ) C = negi ( C ) ; c = mygmodulo_lift ( a , ord , C , vt ) ; S = gadd ( S , gmul ( c , gel ( V , me * me + 1 ) ) ) ; } gel ( R , m + 1 ) = S ; } return degpol ( Pn ) > 1 ? gmodulo ( R , Pn ) : R ; }
CHI is a character defined modulo N4
CHI is a character defined modulo N4
/* (e,ND) = 1; skip i = 1: e = 1, done above */