Esempio n. 1
0
/* return Bs: if r a root of sigma_i(P), |r| < Bs[i] */
static GEN
nf_root_bounds(GEN P, GEN T)
{
  long lR, i, j, l, prec;
  GEN Ps, R, V, nf;

  if (RgX_is_rational(P)) return logmax_modulus_bound(P);
  T = get_nfpol(T, &nf);

  P = Q_primpart(P);
  prec = ZXY_get_prec(P);
  l = lg(P);
  if (nf && nfgetprec(nf) >= prec)
    R = gel(nf,6);
  else
    R = roots(T, prec);
  lR = lg(R);
  V = cgetg(lR, t_VEC);
  Ps = cgetg(l, t_POL); /* sigma (P) */
  Ps[1] = P[1];
  for (j=1; j<lg(R); j++)
  {
    GEN r = gel(R,j);
    for (i=2; i<l; i++) gel(Ps,i) = poleval(gel(P,i), r);
    gel(V,j) = logmax_modulus_bound(Ps);
  }
  return V;
}
Esempio n. 2
0
int main()
{
    int degree=0,*coeff,*points,j,k,count = 1;

    while(1)
    {
        scanf("%d",&degree);

        if(degree==-1)
            break;

        j=0;
        coeff = (int*) calloc(degree+1,sizeof(int));
        while(j<=degree)
        {
            scanf("%d",&coeff[degree-j]);
            j++;
        }

        j=0;
        scanf("%d",&k);
        points = (int*) calloc(k,sizeof(int));
        printf("Case %d: \n",count);
        while(j<k)
        {
            scanf("%d",&points[j]);
            printf("%lld\n",poleval(coeff,points[j],degree));
            j++;
        }
        count++;
        free(coeff);
        free(points);
    }

}