bridge/class-master/depend/pari/src/basemath/mftrace.c
/* F 1/2 integral weight */
F 1/2 integral weight
F 1 / 2 integral weight
static GEN
mf2gaexpansion(GEN mf2, GEN F, GEN ga, long n, long prec)
{
  GEN FT = mfmultheta(F), mf = obj_checkbuild(mf2, MF_MF2INIT, &mf2init);
  GEN res, V1, Tres, V2, al, V, gsh;
  long w2, C = itos(gcoeff(ga,2,1)), w = mfcuspcanon_width(MF_get_N(mf), C);
  long ext = ((C & 3L) != 2)? 0: (w+3) >> 2;
  long prec2 = prec + nbits2extraprec((long)M_PI/(2*M_LN2)*sqrt(n + ext));
  res = mfgaexpansion(mf, FT, ga, n + ext, prec2);
  Tres = mfthetaexpansion(ga, n + ext);
  V1 = gel(res,3);
  V2 = gel(Tres,3);
  al = gsub(gel(res,1), gel(Tres,1));
  w2 = itos(gel(Tres,2));
  if (w != itos(gel(res,2)) || w % w2)
    pari_err_BUG("mf2gaexpansion [incorrect w2 or w]");
  if (w2 != w) V2 = bdexpand(V2, w/w2);
  V = RgV_div_RgXn(V1, V2);
  gsh = gfloor(gmulsg(w, al));
  if (!gequal0(gsh))
  {
    al = gsub(al, gdivgs(gsh, w));
    if (gsigne(gsh) > 0)
    {
      V = RgV_shift(V, gsh);
      V = vecslice(V, 1, n + 1);
    }
    else
    {
      long sh = -itos(gsh), i;
      if (sh > ext) pari_err_BUG("mf2gaexpansion [incorrect sh]");
      for (i = 1; i <= sh; i++)
        if (!gequal0(gel(V,i))) pari_err_BUG("mf2gaexpansion [sh too large]");
      V = vecslice(V, sh+1, n + sh+1);
    }
  }
  obj_free(mf); return mkvec3(al, stoi(w), gprec_wtrunc(V, prec));
}
static GEN mf2gaexpansion ( GEN mf2 , GEN F , GEN ga , long n , long prec ) { GEN FT = mfmultheta ( F ) , mf = obj_checkbuild ( mf2 , MF_MF2INIT , & mf2init ) ; GEN res , V1 , Tres , V2 , al , V , gsh ; long w2 , C = itos ( gcoeff ( ga , 2 , 1 ) ) , w = mfcuspcanon_width ( MF_get_N ( mf ) , C ) ; long ext = ( ( C & 3L ) != 2 ) ? 0 : ( w + 3 ) >> 2 ; long prec2 = prec + nbits2extraprec ( ( long ) M_PI / ( 2 * M_LN2 ) * sqrt ( n + ext ) ) ; res = mfgaexpansion ( mf , FT , ga , n + ext , prec2 ) ; Tres = mfthetaexpansion ( ga , n + ext ) ; V1 = gel ( res , 3 ) ; V2 = gel ( Tres , 3 ) ; al = gsub ( gel ( res , 1 ) , gel ( Tres , 1 ) ) ; w2 = itos ( gel ( Tres , 2 ) ) ; if ( w != itos ( gel ( res , 2 ) ) || w % w2 ) pari_err_BUG ( " " ) ; if ( w2 != w ) V2 = bdexpand ( V2 , w / w2 ) ; V = RgV_div_RgXn ( V1 , V2 ) ; gsh = gfloor ( gmulsg ( w , al ) ) ; if ( ! gequal0 ( gsh ) ) { al = gsub ( al , gdivgs ( gsh , w ) ) ; if ( gsigne ( gsh ) > 0 ) { V = RgV_shift ( V , gsh ) ; V = vecslice ( V , 1 , n + 1 ) ; } else { long sh = - itos ( gsh ) , i ; if ( sh > ext ) pari_err_BUG ( " " ) ; for ( i = 1 ; i <= sh ; i ++ ) if ( ! gequal0 ( gel ( V , i ) ) ) pari_err_BUG ( " " ) ; V = vecslice ( V , sh + 1 , n + sh + 1 ) ; } } obj_free ( mf ) ; return mkvec3 ( al , stoi ( w ) , gprec_wtrunc ( V , prec ) ) ; }
F 1/2 integral weight
F 1 / 2 integral weight