bridge/class-master/depend/pari/src/basemath/mftrace.c
/* integral weight, new space for primitive quadratic character CHIP;
 * MF = vector of embedded eigenforms coefs on mfbasis, by orbit.
 * Assume N > Q > 1 and (Q,f(CHIP)) = 1 */
integral weight, new space for primitive quadratic character CHIP;
MF = vector of embedded eigenforms coefs on mfbasis, by orbit.
integral weight new space for primitive quadratic character CHIP ; MF = vector of embedded eigenforms coefs on mfbasis by orbit .
static GEN
mfatkineigenquad(GEN mf, GEN CHIP, long Q, GEN MF, long bitprec)
{
  GEN L0, la2, S, F, vP, tau, wtau, Z, va, vb, den, coe, sqrtQ, sqrtN;
  GEN M, gN, gk = MF_get_gk(mf);
  long N0, x, yq, i, j, lF, dim, muQ, prec = nbits2prec(bitprec);
  long N = MF_get_N(mf), k = itos(gk), NQ = N / Q;
  F = MF_get_newforms(mf);
  vP = MF_get_fields(mf);
  lF = lg(F);
  Z = cgetg(lF, t_VEC);
  S = MF_get_S(mf); dim = lg(S) - 1;
  muQ = mymoebiusu(Q);
  if (muQ)
  {
    GEN SQ = cgetg(dim+1,t_VEC), Qk = gpow(stoi(Q), sstoQ(k-2, 2), prec);
    long i, bit2 = bitprec >> 1;
    for (j = 1; j <= dim; j++) gel(SQ,j) = mfak_i(gel(S,j), Q);
    for (i = 1; i < lF; i++)
    {
      GEN S = RgV_dotproduct(gel(F,i), SQ), T = gel(vP,i);
      long e;
      if (degpol(T) > 1 && typ(S) != t_POLMOD) S = gmodulo(S, T);
      S = grndtoi(gdiv(conjvec(S, prec), Qk), &e);
      if (e > -bit2) pari_err_PREC("mfatkineigenquad");
      if (muQ == -1) S = gneg(S);
      gel(Z,i) = S;
    }
    return Z;
  }
  la2 = mfchareval_i(CHIP, Q); 
  (void)cbezout(Q, NQ, &x, &yq);
  sqrtQ = sqrtr_abs(utor(Q,prec));
  tau = mkcomplex(gadd(sstoQ(-1, NQ), ginv(utoi(1000))),
                  divru(sqrtQ, N));
  den = gaddgs(gmulsg(NQ, tau), 1);
  wtau = gdiv(gsub(gmulsg(x, tau), sstoQ(yq, Q)), den);
  coe = gpowgs(gmul(sqrtQ, den), k);
  sqrtN = sqrtr_abs(utor(N,prec));
  tau  = mulcxmI(gmul(tau,  sqrtN));
  wtau = mulcxmI(gmul(wtau, sqrtN));
  gN = utoipos(N);
  L0 = mfthetaancreate(NULL, gN, gk); 
  N0 = maxss(lfunthetacost(L0,real_i(tau), 0,bitprec),
             lfunthetacost(L0,real_i(wtau),0,bitprec));
  M = mfcoefs_mf(mf, N0, 1);
  va = cgetg(dim+1, t_VEC);
  vb = cgetg(dim+1, t_VEC);
  for (j = 1; j <= dim; j++)
  {
    GEN L, v = vecslice(gel(M,j), 2, N0+1); 
    settyp(v, t_VEC); L = mfthetaancreate(v, gN, gk);
    gel(va,j) = lfuntheta(L, tau,0,bitprec);
    gel(vb,j) = lfuntheta(L,wtau,0,bitprec);
  }
  for (i = 1; i < lF; i++)
  {
    GEN z, FE = gel(MF,i);
    long l = lg(FE);
    z = cgetg(l, t_VEC);
    for (j = 1; j < l; j++)
    {
      GEN f = gel(FE,j), a = RgV_dotproduct(va,f), b = RgV_dotproduct(vb,f);
      GEN la = ground( gdiv(b, gmul(a,coe)) );
      if (!gequal(gsqr(la), la2)) pari_err_PREC("mfatkineigenquad");
      if (typ(la) == t_INT)
      {
        if (j != 1) pari_err_BUG("mfatkineigenquad");
        z = const_vec(l-1, la); break;
      }
      gel(z,j) = la;
    }
    gel(Z,i) = z;
  }
  return Z;
}
static GEN mfatkineigenquad ( GEN mf , GEN CHIP , long Q , GEN MF , long bitprec ) { GEN L0 , la2 , S , F , vP , tau , wtau , Z , va , vb , den , coe , sqrtQ , sqrtN ; GEN M , gN , gk = MF_get_gk ( mf ) ; long N0 , x , yq , i , j , lF , dim , muQ , prec = nbits2prec ( bitprec ) ; long N = MF_get_N ( mf ) , k = itos ( gk ) , NQ = N / Q ; F = MF_get_newforms ( mf ) ; vP = MF_get_fields ( mf ) ; lF = lg ( F ) ; Z = cgetg ( lF , t_VEC ) ; S = MF_get_S ( mf ) ; dim = lg ( S ) - 1 ; muQ = mymoebiusu ( Q ) ; if ( muQ ) { GEN SQ = cgetg ( dim + 1 , t_VEC ) , Qk = gpow ( stoi ( Q ) , sstoQ ( k - 2 , 2 ) , prec ) ; long i , bit2 = bitprec >> 1 ; for ( j = 1 ; j <= dim ; j ++ ) gel ( SQ , j ) = mfak_i ( gel ( S , j ) , Q ) ; for ( i = 1 ; i < lF ; i ++ ) { GEN S = RgV_dotproduct ( gel ( F , i ) , SQ ) , T = gel ( vP , i ) ; long e ; if ( degpol ( T ) > 1 && typ ( S ) != t_POLMOD ) S = gmodulo ( S , T ) ; S = grndtoi ( gdiv ( conjvec ( S , prec ) , Qk ) , & e ) ; if ( e > - bit2 ) pari_err_PREC ( " " ) ; if ( muQ == -1 ) S = gneg ( S ) ; gel ( Z , i ) = S ; } return Z ; } la2 = mfchareval_i ( CHIP , Q ) ; ( void ) cbezout ( Q , NQ , & x , & yq ) ; sqrtQ = sqrtr_abs ( utor ( Q , prec ) ) ; tau = mkcomplex ( gadd ( sstoQ ( -1 , NQ ) , ginv ( utoi ( 1000 ) ) ) , divru ( sqrtQ , N ) ) ; den = gaddgs ( gmulsg ( NQ , tau ) , 1 ) ; wtau = gdiv ( gsub ( gmulsg ( x , tau ) , sstoQ ( yq , Q ) ) , den ) ; coe = gpowgs ( gmul ( sqrtQ , den ) , k ) ; sqrtN = sqrtr_abs ( utor ( N , prec ) ) ; tau = mulcxmI ( gmul ( tau , sqrtN ) ) ; wtau = mulcxmI ( gmul ( wtau , sqrtN ) ) ; gN = utoipos ( N ) ; L0 = mfthetaancreate ( NULL , gN , gk ) ; N0 = maxss ( lfunthetacost ( L0 , real_i ( tau ) , 0 , bitprec ) , lfunthetacost ( L0 , real_i ( wtau ) , 0 , bitprec ) ) ; M = mfcoefs_mf ( mf , N0 , 1 ) ; va = cgetg ( dim + 1 , t_VEC ) ; vb = cgetg ( dim + 1 , t_VEC ) ; for ( j = 1 ; j <= dim ; j ++ ) { GEN L , v = vecslice ( gel ( M , j ) , 2 , N0 + 1 ) ; settyp ( v , t_VEC ) ; L = mfthetaancreate ( v , gN , gk ) ; gel ( va , j ) = lfuntheta ( L , tau , 0 , bitprec ) ; gel ( vb , j ) = lfuntheta ( L , wtau , 0 , bitprec ) ; } for ( i = 1 ; i < lF ; i ++ ) { GEN z , FE = gel ( MF , i ) ; long l = lg ( FE ) ; z = cgetg ( l , t_VEC ) ; for ( j = 1 ; j < l ; j ++ ) { GEN f = gel ( FE , j ) , a = RgV_dotproduct ( va , f ) , b = RgV_dotproduct ( vb , f ) ; GEN la = ground ( gdiv ( b , gmul ( a , coe ) ) ) ; if ( ! gequal ( gsqr ( la ) , la2 ) ) pari_err_PREC ( " " ) ; if ( typ ( la ) == t_INT ) { if ( j != 1 ) pari_err_BUG ( " " ) ; z = const_vec ( l - 1 , la ) ; break ; } gel ( z , j ) = la ; } gel ( Z , i ) = z ; } return Z ; }
integral weight, new space for primitive quadratic character CHIP;
 MF = vector of embedded eigenforms coefs on mfbasis, by orbit.
integral weight new space for primitive quadratic character CHIP ; MF = vector of embedded eigenforms coefs on mfbasis by orbit .
/* Q coprime to FC */ /* 1 or -1 */ /* only for thetacost */ /* remove a0 */