bridge/class-master/depend/pari/src/basemath/arith1.c
/* Ramanujan tau function for p prime */
Ramanujan tau function for p prime
Ramanujan tau function for p prime
static GEN
tauprime(GEN p)
{
  pari_sp av = avma, av2;
  GEN s, p2, p2_7, p_9, T;
  ulong lim, t, tin;
  if (absequaliu(p, 2)) return utoineg(24);
  p2 = sqri(p);
  p2_7 = mului(7, p2);
  p_9 = mului(9, p);
  av2 = avma;
  lim = itou(sqrtint(p));
  tin = mod4(p) == 3? 1: 0;
  s = gen_0;
  for (t = 1; t <= lim; ++t)
  {
    GEN h, a, t2 = sqru(t), D = shifti(subii(p, t2), 2); 
    h = ((t&1UL) == tin)? hclassno6(D): Hspec(D);
    a = mulii(powiu(t2,3), addii(p2_7, mulii(t2, subii(shifti(t2,2), p_9))));
    s = addii(s, mulii(a,h));
    if (!(t & 255)) s = gerepileuptoint(av2, s);
  }
  T = subii(shifti(mulii(p2_7, subiu(p,1)), 2), addiu(mului(90,p), 35));
  s = shifti(diviuexact(s, 3), 6);
  return gerepileuptoint(av, subii(mulii(mulii(p2,p),T), addui(1, s)));
}
static GEN tauprime ( GEN p ) { pari_sp av = avma , av2 ; GEN s , p2 , p2_7 , p_9 , T ; ulong lim , t , tin ; if ( absequaliu ( p , 2 ) ) return utoineg ( 24 ) ; p2 = sqri ( p ) ; p2_7 = mului ( 7 , p2 ) ; p_9 = mului ( 9 , p ) ; av2 = avma ; lim = itou ( sqrtint ( p ) ) ; tin = mod4 ( p ) == 3 ? 1 : 0 ; s = gen_0 ; for ( t = 1 ; t <= lim ; ++ t ) { GEN h , a , t2 = sqru ( t ) , D = shifti ( subii ( p , t2 ) , 2 ) ; h = ( ( t & 1UL ) == tin ) ? hclassno6 ( D ) : Hspec ( D ) ; a = mulii ( powiu ( t2 , 3 ) , addii ( p2_7 , mulii ( t2 , subii ( shifti ( t2 , 2 ) , p_9 ) ) ) ) ; s = addii ( s , mulii ( a , h ) ) ; if ( ! ( t & 255 ) ) s = gerepileuptoint ( av2 , s ) ; } T = subii ( shifti ( mulii ( p2_7 , subiu ( p , 1 ) ) , 2 ) , addiu ( mului ( 90 , p ) , 35 ) ) ; s = shifti ( diviuexact ( s , 3 ) , 6 ) ; return gerepileuptoint ( av , subii ( mulii ( mulii ( p2 , p ) , T ) , addui ( 1 , s ) ) ) ; }
Ramanujan tau function for p prime
Ramanujan tau function for p prime
/* p > 2 */ /* 4(p-t^2) */ /* t mod 2 != tin <=> D not fundamental at 2 */ /* 28p^3 - 28p^2 - 90p - 35 */