From 469bdc80712dbf9c12562059dc4594620b59a076 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Wed, 7 Oct 2015 12:51:41 +0000 Subject: Support MPFR floats in numkondo Remove '-D' option (error tolerance) in numkondo --- src/coefficient.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'src/coefficient.c') diff --git a/src/coefficient.c b/src/coefficient.c index c26b668..d4cb6eb 100644 --- a/src/coefficient.c +++ b/src/coefficient.c @@ -18,6 +18,10 @@ limitations under the License. #include #include +#include +// define MPFR_USE_VA_LIST to enable the use of mpfr_inits and mpfr_clears +#define MPFR_USE_VA_LIST +#include #include "definitions.cpp" #include "rational.h" #include "istring.h" @@ -721,7 +725,7 @@ int evalcoef(RCC rccs, Coefficient coef, long double* out){ int i,j; long double num_factor; - *out=0; + *out=0.; // for each monomial for(i=0;i0){ + mpfr_pow_si(y, rccs.values[intlist_find_err(rccs.indices,rccs.length,coef.denoms[i].index)], coef.denoms[i].power, MPFR_RNDN); + mpfr_div(x, num_factor, y, MPFR_RNDN); + mpfr_set(num_factor, x, MPFR_RNDN); + } + + number_mpfr_val(Z, coef.nums[i]); + mpfr_mul(x, num_factor, Z, MPFR_RNDN); + mpfr_add(y, x, out, MPFR_RNDN); + mpfr_set(out, y, MPFR_RNDN); + mpfr_clear(Z); + } + + // free numbers + mpfr_clears(num_factor, x, y, (mpfr_ptr)NULL); + + return(0); +} -- cgit v1.2.3-70-g09d2