Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jauslin <ian.jauslin@roma1.infn.it>2015-10-07 12:51:41 +0000
committerIan Jauslin <ian.jauslin@roma1.infn.it>2015-10-07 13:00:23 +0000
commit469bdc80712dbf9c12562059dc4594620b59a076 (patch)
treec6da40a884899110d102d82a7a778f2b3afae702 /src/number.c
parente7aa6859f08565d58684fa4b9c40fed716f0ba17 (diff)
Support MPFR floats in numkondov1.4
Remove '-D' option (error tolerance) in numkondo
Diffstat (limited to 'src/number.c')
-rw-r--r--src/number.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/number.c b/src/number.c
index 5d4cd18..e63427f 100644
--- a/src/number.c
+++ b/src/number.c
@@ -18,6 +18,10 @@ limitations under the License.
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
+#include <stdarg.h>
+// define MPFR_USE_VA_LIST to enable the use of mpfr_inits and mpfr_clears
+#define MPFR_USE_VA_LIST
+#include <mpfr.h>
#include "istring.h"
#include "definitions.cpp"
#include "tools.h"
@@ -358,6 +362,30 @@ long double number_double_val(Number x){
}
return(ret);
}
+// approximate numerical expression (as mpfr float)
+int number_mpfr_val(mpfr_t out, Number x){
+ int i;
+ // auxiliary variables (do not initialize A)
+ mpfr_t A,b,c;
+ mpfr_inits(b,c, (mpfr_ptr)NULL);
+
+ mpfr_init(out);
+ mpfr_set_zero(out,1);
+
+ for(i=0;i<x.length;i++){
+ if(x.scalars[i].numerator!=0){
+ mpfr_sqrt_ui(b, x.base[i], MPFR_RNDN);
+ Q_mpfr_value(A, x.scalars[i]);
+ mpfr_mul(c, A, b, MPFR_RNDN);
+ mpfr_add(b, out, c, MPFR_RNDN);
+ mpfr_set(out, b, MPFR_RNDN);
+ }
+ }
+
+ mpfr_clears(A,b,c, (mpfr_ptr)NULL);
+
+ return(0);
+}
// print to string