Karim Belabas on Wed, 27 Jan 2016 15:23:51 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Precision in the PARI library (gp_read_str) |
* Bill Allombert [2016-01-27 14:58]: [...] > If you use the master branch you can change the > default precision locally with: > > push_localprec(BIGDEFAULTPREC); > gp_read_str(....) > pop_localprec(); It's not the first time this problem is mentioned. Bill, how about exporting utility functions such as GEN gp_read_str_bitprec(const char *s, long bitprec) { GEN x; push_localbitprec(bitprec); x = gp_read_str(s); pop_localprec(); return x; } GEN gp_read_str_prec(const char *s, long prec) { return gp_read_str_bitprec(s, prec2nbits(prec)); } ? [Untested]. Other functions could be wrapped in the same way: GENtostr and variants, etc. Then a single generic wrapper would implement all such variants. GEN wrap_read_bitprec(GEN (*eval)(const char *), const char *s, long bitprec) { GEN x; push_localbitprec(bitprec); x = eval(s); pop_localprec(); return x; } GEN gp_read_str_bitprec(const char *s, long bit) { return wrap_read_bitprec(&gp_read_str, s, bit); } [Untested again] Cheers, K.B. -- Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 Universite de Bordeaux Fax: (+33) (0)5 40 00 69 50 351, cours de la Liberation http://www.math.u-bordeaux.fr/~kbelabas/ F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP] `