Loïc Grenié on Thu, 09 Oct 2014 22:41:34 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: experimental localprec() feature |
2014-10-09 17:37 GMT+02:00 Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>: > Dear PARI developpers, > > I have created an experimental git branch bill-localprec that adds a command > localprec() which allow to set the real precision locally: > > Consider the function: > f(s)=Pi^s > and > s=precision(1.,100) > > Pi is computed using the current precision. > If we want the resut to be correct to the precision of s, > we could do > > g(s)= > { my(prec=default(realprecision)); > default(realprecision,precision(s)); > my(r=Pi^s); > default(realprecision,prec); > r; > } > > which is rather cumbersome. Using localprec() it is sufficient to say: > > g(s)=localprec(precision(s));Pi^s > > Also it is safer since the value of realprecision is restored even if an error > occurs. Nice! Thanks! That's something that I have dreamed for a long time. Loïc