Andreas Enge on Fri, 23 Jul 2021 12:55:04 +0200


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

Re: Making a polynomial and evaluating it many times from C++


Am Fri, Jul 23, 2021 at 12:49:02AM +0200 schrieb Bill Allombert:
> > Another question, perhaps subjective: would it perhaps make more sense
> > to just export the coefficients of the polynomial to my C++ code, and
> > then use MPFR directly to evaluate it? That way Pari does only the
> > symbolic manipulation, which it is more suited for, I guess?
> PARI t_REAL format is not compatible with MPFR, so it is not that
> simple.

If you want to go this road, you can use the PartiTwine C library:
   http://www.multiprecision.org/paritwine/
It contains functions to move between GMP/MPFR/MPC and ARB on one hand
and PARI on the other hand; in particular the functions
   mpfr_set_GEN
   mpfr_get_GEN

So far, we have not added functions for transforming polynomials between
PARI and MPFRCX:
   http://www.multiprecision.org/mpfrcx/
but that would be entirely possible.

The MPFRCX library has code for evaluating polynomials (with MPFR or MPC
coefficients) in one or several arguments:
   mpfrx_eval
   mpcx_eval
   mpfrx_multieval
   mpcx_multieval
Multievaluation implements an asymptotically fast algorithm for generic
arguments; one could write special code for arguments in an arithmetic
progression, for instance.

Like PARI, MPFRCX has no semantics ;-)  Otherwise said, unlike the MPFR,
MPC or ARB libraries, it makes no guarantees on the correctness of the
results.

Andreas