bridge/class-master/depend/pari/src/basemath/rootpol.c
/* return the roots of p with absolute error bit */
return the roots of p with absolute error bit
return the roots of p with absolute error bit
static GEN
roots_com(GEN q, long bit)
{
  GEN L, p;
  long v = RgX_valrem_inexact(q, &p);
  int ex = isexactpol(p);
  if (!ex) p = RgX_normalize1(p);
  if (lg(p) == 3)
    L = cgetg(1,t_VEC); 
  else
    L = ex? solve_exact_pol(p,bit): all_roots(p,bit);
  if (v)
  {
    GEN M, z, t = gel(q,2);
    long i, x, y, l, n;
    if (isrationalzero(t)) x = -bit;
    else
    {
      n = gexpo(t);
      x = n / v; l = degpol(q);
      for (i = v; i <= l; i++)
      {
        t  = gel(q,i+2);
        if (isrationalzero(t)) continue;
        y = (n - gexpo(t)) / i;
        if (y < x) x = y;
      }
    }
    z = real_0_bit(x); l = v + lg(L);
    M = cgetg(l, t_VEC); L -= v;
    for (i = 1; i <= v; i++) gel(M,i) = z;
    for (     ; i <  l; i++) gel(M,i) = gel(L,i);
    L = M;
  }
  return L;
}
static GEN roots_com ( GEN q , long bit ) { GEN L , p ; long v = RgX_valrem_inexact ( q , & p ) ; int ex = isexactpol ( p ) ; if ( ! ex ) p = RgX_normalize1 ( p ) ; if ( lg ( p ) == 3 ) L = cgetg ( 1 , t_VEC ) ; else L = ex ? solve_exact_pol ( p , bit ) : all_roots ( p , bit ) ; if ( v ) { GEN M , z , t = gel ( q , 2 ) ; long i , x , y , l , n ; if ( isrationalzero ( t ) ) x = - bit ; else { n = gexpo ( t ) ; x = n / v ; l = degpol ( q ) ; for ( i = v ; i <= l ; i ++ ) { t = gel ( q , i + 2 ) ; if ( isrationalzero ( t ) ) continue ; y = ( n - gexpo ( t ) ) / i ; if ( y < x ) x = y ; } } z = real_0_bit ( x ) ; l = v + lg ( L ) ; M = cgetg ( l , t_VEC ) ; L -= v ; for ( i = 1 ; i <= v ; i ++ ) gel ( M , i ) = z ; for ( ; i < l ; i ++ ) gel ( M , i ) = gel ( L , i ) ; L = M ; } return L ; }
return the roots of p with absolute error bit
return the roots of p with absolute error bit
/* constant polynomial */