bridge/class-master/depend/pari/src/basemath/lfun.c
/* Find root number and/or residues when L-function coefficients and
   conductor are known. For the moment at most a single residue allowed. */
Find root number and/or residues when L-function coefficients and
conductor are known. For the moment at most a single residue allowed.
Find root number and / or residues when L - function coefficients and conductor are known . For the moment at most a single residue allowed .
GEN
lfunrootres(GEN data, long bitprec)
{
  pari_sp ltop = avma;
  GEN w, r, R, a, b, e, v, v2, be, ldata, linit;
  long k, prec;
  ldata = lfunmisc_to_ldata_shallow(data);
  r = ldata_get_residue(ldata);
  k = ldata_get_k(ldata);
  if (r) r = normalize_simple_pole(r, stoi(k));
  if (!r || residues_known(r))
  {
    w = lfunrootno(data, bitprec);
    if (!r)
      r = R = gen_0;
    else
      R = lfunrtoR_eno(ldata, w, nbits2prec(bitprec));
    return gerepilecopy(ltop, mkvec3(r, R, w));
  }
  linit = lfunthetacheckinit(data, dbltor(sqrt(0.5)), 0, bitprec);
  prec = nbits2prec(bitprec);
  if (lg(r) > 2) pari_err_IMPL("multiple poles in lfunrootres");
  be = gmael(r, 1, 1);
  w = ldata_get_rootno(ldata);
  if (ldata_isreal(ldata) && gequalm1(w))
    R = lfuntheta(linit, gen_1, 0, bitprec);
  else
  {
    lfunthetaspec(linit, bitprec, &v2, &v);
    if (gequalgs(gmulsg(2, be), k)) pari_err_IMPL("pole at k/2 in lfunrootres");
    if (gequalgs(be, k))
    {
      GEN p2k = int2n(k);
      a = conj_i(gsub(gmul(p2k, v), v2));
      b = subiu(p2k, 1);
      e = gmul(gsqrt(p2k, prec), gsub(v2, v));
    }
    else
    {
      GEN tk2 = gsqrt(int2n(k), prec);
      GEN tbe = gpow(gen_2, be, prec);
      GEN tkbe = gpow(gen_2, gdivgs(gsubsg(k, be), 2), prec);
      a = conj_i(gsub(gmul(tbe, v), v2));
      b = gsub(gdiv(tbe, tkbe), tkbe);
      e = gsub(gmul(gdiv(tbe, tk2), v2), gmul(tk2, v));
    }
    if (!isintzero(w)) R = gdiv(gsub(e, gmul(a, w)), b);
    else
    { 
      GEN t0  = mkfrac(stoi(11),stoi(10));
      GEN th1 = lfuntheta(linit, t0,  0, bitprec);
      GEN th2 = lfuntheta(linit, ginv(t0), 0, bitprec);
      GEN tbe = gpow(t0, gmulsg(2, be), prec);
      GEN tkbe = gpow(t0, gsubsg(k, be), prec);
      GEN tk2 = gpowgs(t0, k);
      GEN c = conj_i(gsub(gmul(tbe, th1), th2));
      GEN d = gsub(gdiv(tbe, tkbe), tkbe);
      GEN f = gsub(gmul(gdiv(tbe, tk2), th2), gmul(tk2, th1));
      GEN D = gsub(gmul(a, d), gmul(b, c));
      w = gdiv(gsub(gmul(d, e), gmul(b, f)), D);
      R = gdiv(gsub(gmul(a, f), gmul(c, e)), D);
    }
  }
  r = normalize_simple_pole(Rtor(be, R, ldata, prec), be);
  R = lfunrtoR_i(ldata, r, w, prec);
  return gerepilecopy(ltop, mkvec3(r, R, ropm1(w, prec)));
}
GEN lfunrootres ( GEN data , long bitprec ) { pari_sp ltop = avma ; GEN w , r , R , a , b , e , v , v2 , be , ldata , linit ; long k , prec ; ldata = lfunmisc_to_ldata_shallow ( data ) ; r = ldata_get_residue ( ldata ) ; k = ldata_get_k ( ldata ) ; if ( r ) r = normalize_simple_pole ( r , stoi ( k ) ) ; if ( ! r || residues_known ( r ) ) { w = lfunrootno ( data , bitprec ) ; if ( ! r ) r = R = gen_0 ; else R = lfunrtoR_eno ( ldata , w , nbits2prec ( bitprec ) ) ; return gerepilecopy ( ltop , mkvec3 ( r , R , w ) ) ; } linit = lfunthetacheckinit ( data , dbltor ( sqrt ( 0.5 ) ) , 0 , bitprec ) ; prec = nbits2prec ( bitprec ) ; if ( lg ( r ) > 2 ) pari_err_IMPL ( " " ) ; be = gmael ( r , 1 , 1 ) ; w = ldata_get_rootno ( ldata ) ; if ( ldata_isreal ( ldata ) && gequalm1 ( w ) ) R = lfuntheta ( linit , gen_1 , 0 , bitprec ) ; else { lfunthetaspec ( linit , bitprec , & v2 , & v ) ; if ( gequalgs ( gmulsg ( 2 , be ) , k ) ) pari_err_IMPL ( " " ) ; if ( gequalgs ( be , k ) ) { GEN p2k = int2n ( k ) ; a = conj_i ( gsub ( gmul ( p2k , v ) , v2 ) ) ; b = subiu ( p2k , 1 ) ; e = gmul ( gsqrt ( p2k , prec ) , gsub ( v2 , v ) ) ; } else { GEN tk2 = gsqrt ( int2n ( k ) , prec ) ; GEN tbe = gpow ( gen_2 , be , prec ) ; GEN tkbe = gpow ( gen_2 , gdivgs ( gsubsg ( k , be ) , 2 ) , prec ) ; a = conj_i ( gsub ( gmul ( tbe , v ) , v2 ) ) ; b = gsub ( gdiv ( tbe , tkbe ) , tkbe ) ; e = gsub ( gmul ( gdiv ( tbe , tk2 ) , v2 ) , gmul ( tk2 , v ) ) ; } if ( ! isintzero ( w ) ) R = gdiv ( gsub ( e , gmul ( a , w ) ) , b ) ; else { GEN t0 = mkfrac ( stoi ( 11 ) , stoi ( 10 ) ) ; GEN th1 = lfuntheta ( linit , t0 , 0 , bitprec ) ; GEN th2 = lfuntheta ( linit , ginv ( t0 ) , 0 , bitprec ) ; GEN tbe = gpow ( t0 , gmulsg ( 2 , be ) , prec ) ; GEN tkbe = gpow ( t0 , gsubsg ( k , be ) , prec ) ; GEN tk2 = gpowgs ( t0 , k ) ; GEN c = conj_i ( gsub ( gmul ( tbe , th1 ) , th2 ) ) ; GEN d = gsub ( gdiv ( tbe , tkbe ) , tkbe ) ; GEN f = gsub ( gmul ( gdiv ( tbe , tk2 ) , th2 ) , gmul ( tk2 , th1 ) ) ; GEN D = gsub ( gmul ( a , d ) , gmul ( b , c ) ) ; w = gdiv ( gsub ( gmul ( d , e ) , gmul ( b , f ) ) , D ) ; R = gdiv ( gsub ( gmul ( a , f ) , gmul ( c , e ) ) , D ) ; } } r = normalize_simple_pole ( Rtor ( be , R , ldata , prec ) , be ) ; R = lfunrtoR_i ( ldata , r , w , prec ) ; return gerepilecopy ( ltop , mkvec3 ( r , R , ropm1 ( w , prec ) ) ) ; }
Find root number and/or residues when L-function coefficients and
conductor are known.
Find root number and / or residues when L - function coefficients and conductor are known .
/* Now residue unknown, and r = [[be,0]]. */ /* Now residue unknown, r = [[be,0]], and w unknown. */