Pascal Molin on Sat, 17 Dec 2016 15:52:34 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Ratpoint


and me this one (no options)

ratpoints(f,lim=10^4) = {
  my(coeffs, command);
  if(type(f)=="t_POL",f=Vecrev(f));
  coeffs = concat(apply(s->Str(s," "),f));
  command = Strprintf("%s '%s' %i -q | tr '(:)' '[,]'",
    "./ratpoints", coeffs, lim);
  eval(externstr(command));
}

2016-12-17 15:46 GMT+01:00 Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>:
On Sat, Dec 17, 2016 at 10:21:46AM +0100, Henri.Cohen@math.u-bordeaux.fr wrote:
> If you have it compiled in your directory, I have this very old script which
> may work (not tested in 5 years):
>
> ratpoints(Curve,bound=1024,flags="")=
> {
>   local(lc,infty);
>   lc = length(Curve);
>   if (lc<=1,error("The polynomial must have degree >=1"));
>   if (lc>=12,error("The polynomial must have degree <=10"));
>   Curve=concat(vector(lc,i,Str(Curve[lc+1-i]" ")));
>   Curve=extern(concat(["echo \\{\\[ 0; ratpoints '",Curve,"' ",bound," -q
> ",fla\
> gs," | sed -e 's/(\\([-/0-9]\\+\\) : \\([-/0-9]\\+\\))/,[\\1 ,\\2 ]/'; echo
> \\\
> ]\\}"]));
>   lc = length(Curve);
>   if(lc==1 || (lc==2 && Curve[2][2]==0),return([]));
>   infty= Curve[2][2]==0;
>   vector(lc-1-infty,i,Curve[i+1+infty][1]/Curve[i+1+infty][2])
> }

In that spirit, I use this one:

ratpoints(pol,lim:small=1,singlepoint=1)=
{
  my(v=concat(apply(x->concat(x," "),Vecrev(pol))));
  my(opt=if(singlepoint," -1",""));
  my(e=externstr(Str("./ratpoints '",v,"' ",lim, " -q -i ",opt," | tr
'():' '[],'")));
  my(L=apply(x->[x[1],x[2]]/x[3],eval(e)));
  if(#L && singlepoint,L[1],L);
}

Cheers,
Bill.