bridge/class-master/depend/pari/src/basemath/mftrace.c
/* contribution of elliptic matrices to trace formula */
contribution of elliptic matrices to trace formula
contribution of elliptic matrices to trace formula
static GEN
TA2(long N, long k, GEN VCHI, long n, GEN SQRTS, GEN MUP, GEN GCD)
{
  const long n4 = n << 2, N4 = N << 2, nu = k - 2;
  const long st = (!odd(N) && odd(n)) ? 2 : 1;
  long limt, t;
  GEN S, Q;
  limt = usqrt(n4);
  if (limt*limt == n4) limt--;
  Q = nu > 3 ? ZX_z_unscale(mfrhopol(nu), n) : NULL;
  S = gen_0;
  for (t = odd(k)? st: 0; t <= limt; t += st) 
  {
    pari_sp av = avma;
    long t2 = t*t, D = n4 - t2, F, D0, NF;
    GEN sh, li;
    li = gel(SQRTS, (smodss(-D - 1, N4) >> 1) + 1);
    if (lg(li) == 1) continue;
    D0 = mycoredisc2neg(D, &F);
    NF = myugcd(GCD, F);
    if (NF == 1)
    { 
      GEN mut = mutg1(t, N, VCHI, li, GCD);
      if (!mut) { avma = av; continue; }
      sh = gmul(sstoQ(hclassno6u_i(D,D0,F),6), mut);
    }
    else
    {
      GEN v = mutglistall(t, N, NF, VCHI, n, MUP, li, GCD);
      GEN DF = mydivisorsu(F);
      long i, lDF = lg(DF);
      sh = gen_0;
      for (i = 1; i < lDF; i++)
      {
        long Ff, f = DF[i], g = myugcd(GCD, f);
        GEN mut = gel(v, g);
        if (gequal0(mut)) continue;
        Ff = DF[lDF-i]; 
        if (Ff == 1) sh = gadd(sh, mut);
        else
        {
          GEN P = gel(myfactoru(Ff), 1);
          long j, lP = lg(P);
          for (j = 1; j < lP; j++) { long p = P[j]; Ff -= kross(D0, p)*Ff/p; }
          sh = gadd(sh, gmulsg(Ff, mut));
        }
      }
      if (gequal0(sh)) { avma = av; continue; }
      if (D0 == -3) sh = gdivgs(sh, 3);
      else if (D0 == -4) sh = gdivgs(sh, 2);
      else sh = gmulgs(sh, myh(D0));
    }
    S = gerepileupto(av, gadd(S, mfrhopowsimp(Q,sh,nu,t,t2,n)));
  }
  return S;
}
static GEN TA2 ( long N , long k , GEN VCHI , long n , GEN SQRTS , GEN MUP , GEN GCD ) { const long n4 = n << 2 , N4 = N << 2 , nu = k - 2 ; const long st = ( ! odd ( N ) && odd ( n ) ) ? 2 : 1 ; long limt , t ; GEN S , Q ; limt = usqrt ( n4 ) ; if ( limt * limt == n4 ) limt -- ; Q = nu > 3 ? ZX_z_unscale ( mfrhopol ( nu ) , n ) : NULL ; S = gen_0 ; for ( t = odd ( k ) ? st : 0 ; t <= limt ; t += st ) { pari_sp av = avma ; long t2 = t * t , D = n4 - t2 , F , D0 , NF ; GEN sh , li ; li = gel ( SQRTS , ( smodss ( - D - 1 , N4 ) >> 1 ) + 1 ) ; if ( lg ( li ) == 1 ) continue ; D0 = mycoredisc2neg ( D , & F ) ; NF = myugcd ( GCD , F ) ; if ( NF == 1 ) { GEN mut = mutg1 ( t , N , VCHI , li , GCD ) ; if ( ! mut ) { avma = av ; continue ; } sh = gmul ( sstoQ ( hclassno6u_i ( D , D0 , F ) , 6 ) , mut ) ; } else { GEN v = mutglistall ( t , N , NF , VCHI , n , MUP , li , GCD ) ; GEN DF = mydivisorsu ( F ) ; long i , lDF = lg ( DF ) ; sh = gen_0 ; for ( i = 1 ; i < lDF ; i ++ ) { long Ff , f = DF [ i ] , g = myugcd ( GCD , f ) ; GEN mut = gel ( v , g ) ; if ( gequal0 ( mut ) ) continue ; Ff = DF [ lDF - i ] ; if ( Ff == 1 ) sh = gadd ( sh , mut ) ; else { GEN P = gel ( myfactoru ( Ff ) , 1 ) ; long j , lP = lg ( P ) ; for ( j = 1 ; j < lP ; j ++ ) { long p = P [ j ] ; Ff -= kross ( D0 , p ) * Ff / p ; } sh = gadd ( sh , gmulsg ( Ff , mut ) ) ; } } if ( gequal0 ( sh ) ) { avma = av ; continue ; } if ( D0 == -3 ) sh = gdivgs ( sh , 3 ) ; else if ( D0 == -4 ) sh = gdivgs ( sh , 2 ) ; else sh = gmulgs ( sh , myh ( D0 ) ) ; } S = gerepileupto ( av , gadd ( S , mfrhopowsimp ( Q , sh , nu , t , t2 , n ) ) ) ; } return S ; }
contribution of elliptic matrices to trace formula
contribution of elliptic matrices to trace formula
/* t^2 < 4n */ /* (N,F) = 1 => single value in mutglistall */ /* F/f */