bridge/class-master/depend/pari/src/basemath/mellininv.c
/* Asymptotic expansion of inverse Mellin, to length nlimmax. Set status = 0
 * (regular), 1 (one Hankel determinant vanishes => contfracinit will fail)
 * or 2 (same as 1, but asymptotic expansion is finite!)
 *
 * If status = 2, the asymptotic expansion is finite so return only
 * the necessary number of terms nlim <= nlimmax + d. */
Asymptotic expansion of inverse Mellin, to length nlimmax. Set status = 0
(regular), 1 (one Hankel determinant vanishes => contfracinit will fail)
or 2 (same as 1, but asymptotic expansion is finite!)

If status = 2, the asymptotic expansion is finite so return only
the necessary number of terms nlim <= nlimmax + d.
Asymptotic expansion of inverse Mellin to length nlimmax . Set status = 0 ( regular ) 1 ( one Hankel determinant vanishes = > contfracinit will fail ) or 2 ( same as 1 but asymptotic expansion is finite! ) If status = 2 the asymptotic expansion is finite so return only the necessary number of terms nlim < = nlimmax + d .
static GEN
Klargeinit0(GEN Vga, long nlimmax, long *status)
{
  const long prec = LOWDEFAULTPREC;
  const long d = lg(Vga)-1;
  long k, n, m, cnt;
  GEN pol, SM, nS1, se, vsinh, M, dk;
  if (d==1 || (d==2 && gequal1(gabs(gsub(gel(Vga,1), gel(Vga,2)), prec))))
  { 
    *status = 2; return mkvec(gen_1);
  }
  *status = 0;
  pol = roots_to_pol(gneg(Vga), 0); 
  nS1 = gpowers(gneg(RgX_coeff(pol, d-1)), d);
  dk = gpowers(utoi(d), d-1);
  SM = cgetg(d+3, t_VEC);
  for (m = 0; m <= d; ++m)
  {
    pari_sp btop = avma;
    GEN s = gmul(gdivgs(gel(nS1, m+1), d), binomialuu(d, m));
    for (k = 1; k <= m; ++k)
    {
      GEN e = gmul(gel(nS1, m-k+1), gel(dk, k));
      s = gadd(s, gmul(gmul(e, binomialuu(d-k, m-k)), RgX_coeff(pol, d-k)));
    }
    gel(SM, m+1) = gerepileupto(btop, s);
  }
  se = gdiv(gsinh(RgX_to_ser(pol_x(0), d+2), prec), pol_x(0));
  vsinh = gpowers(se, d);
  M = vectrunc_init(nlimmax + d);
  vectrunc_append(M, gen_1);
  for (n=2, cnt=0; (n <= nlimmax) || cnt; ++n)
  {
    pari_sp btop = avma;
    long p, ld = minss(d, n);
    GEN s = gen_0;
    for (p = 2; p <= ld; ++p)
      s = gadd(s, gmul(fun_vp(p, n-1, d, SM, vsinh), gel(M, n+1-p)));
    s = gerepileupto(btop, gdivgs(s, n-1));
    vectrunc_append(M, s);
    if (!isintzero(s))
    {
      if (n >= nlimmax) break;
      cnt = 0;
    }
    else
    {
      cnt++; *status = 1;
      if (cnt >= d-1) { *status = 2; setlg(M, lg(M) - (d-1)); break; }
    }
  }
  return M;
}
static GEN Klargeinit0 ( GEN Vga , long nlimmax , long * status ) { const long prec = LOWDEFAULTPREC ; const long d = lg ( Vga ) - 1 ; long k , n , m , cnt ; GEN pol , SM , nS1 , se , vsinh , M , dk ; if ( d == 1 || ( d == 2 && gequal1 ( gabs ( gsub ( gel ( Vga , 1 ) , gel ( Vga , 2 ) ) , prec ) ) ) ) { * status = 2 ; return mkvec ( gen_1 ) ; } * status = 0 ; pol = roots_to_pol ( gneg ( Vga ) , 0 ) ; nS1 = gpowers ( gneg ( RgX_coeff ( pol , d - 1 ) ) , d ) ; dk = gpowers ( utoi ( d ) , d - 1 ) ; SM = cgetg ( d + 3 , t_VEC ) ; for ( m = 0 ; m <= d ; ++ m ) { pari_sp btop = avma ; GEN s = gmul ( gdivgs ( gel ( nS1 , m + 1 ) , d ) , binomialuu ( d , m ) ) ; for ( k = 1 ; k <= m ; ++ k ) { GEN e = gmul ( gel ( nS1 , m - k + 1 ) , gel ( dk , k ) ) ; s = gadd ( s , gmul ( gmul ( e , binomialuu ( d - k , m - k ) ) , RgX_coeff ( pol , d - k ) ) ) ; } gel ( SM , m + 1 ) = gerepileupto ( btop , s ) ; } se = gdiv ( gsinh ( RgX_to_ser ( pol_x ( 0 ) , d + 2 ) , prec ) , pol_x ( 0 ) ) ; vsinh = gpowers ( se , d ) ; M = vectrunc_init ( nlimmax + d ) ; vectrunc_append ( M , gen_1 ) ; for ( n = 2 , cnt = 0 ; ( n <= nlimmax ) || cnt ; ++ n ) { pari_sp btop = avma ; long p , ld = minss ( d , n ) ; GEN s = gen_0 ; for ( p = 2 ; p <= ld ; ++ p ) s = gadd ( s , gmul ( fun_vp ( p , n - 1 , d , SM , vsinh ) , gel ( M , n + 1 - p ) ) ) ; s = gerepileupto ( btop , gdivgs ( s , n - 1 ) ) ; vectrunc_append ( M , s ) ; if ( ! isintzero ( s ) ) { if ( n >= nlimmax ) break ; cnt = 0 ; } else { cnt ++ ; * status = 1 ; if ( cnt >= d - 1 ) { * status = 2 ; setlg ( M , lg ( M ) - ( d - 1 ) ) ; break ; } } } return M ; }
Asymptotic expansion of inverse Mellin, to length nlimmax.
Asymptotic expansion of inverse Mellin to length nlimmax .
/* shortcut */ /* d >= 2 */ /* deg(pol) = d */