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/meantools_eval.c
parente7aa6859f08565d58684fa4b9c40fed716f0ba17 (diff)
Support MPFR floats in numkondov1.4
Remove '-D' option (error tolerance) in numkondo
Diffstat (limited to 'src/meantools_eval.c')
-rw-r--r--src/meantools_eval.c64
1 files changed, 58 insertions, 6 deletions
diff --git a/src/meantools_eval.c b/src/meantools_eval.c
index 50fff5b..4f166cd 100644
--- a/src/meantools_eval.c
+++ b/src/meantools_eval.c
@@ -18,16 +18,22 @@ limitations under the License.
#include <stdio.h>
#include <stdlib.h>
+#include <mpfr.h>
#include "parse_file.h"
#include "cli_parser.h"
#include "grouped_polynomial.h"
#include "array.h"
#include "rcc.h"
+#include "rcc_mpfr.h"
#define CP_FLAG_RCCS 1
+#define CP_FLAG_MPFR_PREC 2
+#define CP_FLAG_MPFR_EXP 3
// read command line arguments
int tool_eval_read_args(int argc, const char* argv[], Str_Array* str_args, Meantools_Options* opts){
+ // temporary long int
+ long int tmp_lint;
// file to read the polynomial from in flow mode
const char* file="";
// whether a file was specified on the command-line
@@ -40,6 +46,9 @@ int tool_eval_read_args(int argc, const char* argv[], Str_Array* str_args, Meant
// defaults
// mark rccstring so that it can be recognized whether it has been set or not
(*opts).eval_rccstring.length=-1;
+ // no mpfr
+ (*opts).mpfr_prec=0;
+ (*opts).mpfr_emax=0;
// loop over arguments
for(i=2;i<argc;i++){
@@ -51,6 +60,14 @@ int tool_eval_read_args(int argc, const char* argv[], Str_Array* str_args, Meant
case 'R':
flag=CP_FLAG_RCCS;
break;
+ // mpfr precision
+ case 'P':
+ flag=CP_FLAG_MPFR_PREC;
+ break;
+ // mpfr emax
+ case 'E':
+ flag=CP_FLAG_MPFR_EXP;
+ break;
}
}
}
@@ -59,6 +76,18 @@ int tool_eval_read_args(int argc, const char* argv[], Str_Array* str_args, Meant
str_to_char_array((char*)argv[i], &((*opts).eval_rccstring));
flag=0;
}
+ // mpfr precision
+ else if(flag==CP_FLAG_MPFR_PREC){
+ sscanf(argv[i],"%ld",&tmp_lint);
+ (*opts).mpfr_prec=(mpfr_prec_t)tmp_lint;
+ flag=0;
+ }
+ // mpfr emax
+ else if(flag==CP_FLAG_MPFR_EXP){
+ sscanf(argv[i],"%ld",&tmp_lint);
+ (*opts).mpfr_emax=(mpfr_exp_t)tmp_lint;
+ flag=0;
+ }
// read file name from command-line
else{
file=argv[i];
@@ -78,9 +107,21 @@ int tool_eval(Str_Array str_args, Meantools_Options opts){
int arg_index;
// rccs
RCC rccs;
+ RCC_mpfr rccs_mpfr;
// flow equation
Grouped_Polynomial flow_equation;
+ // whether or not to use mpfr floats
+ int mpfr_flag=0;
+ // set mpfr defaults
+ if(opts.mpfr_prec!=0){
+ mpfr_set_default_prec(opts.mpfr_prec);
+ mpfr_flag=1;
+ }
+ if(opts.mpfr_emax!=0){
+ mpfr_set_emax(opts.mpfr_emax);
+ mpfr_flag=1;
+ }
// parse flow equation
// if there is a unique argument, assume it is the flow equation
@@ -108,22 +149,33 @@ int tool_eval(Str_Array str_args, Meantools_Options opts){
}
// initialize the rccs
- prepare_init(flow_equation.indices,flow_equation.length,&rccs);
+ if(mpfr_flag==0){
+ prepare_init(flow_equation.indices,flow_equation.length,&rccs);
+ }
+ else{
+ prepare_init_mpfr(flow_equation.indices,flow_equation.length,&rccs_mpfr);
+ }
// read rccs from string
if(opts.eval_rccstring.length!=-1){
- parse_init_cd(opts.eval_rccstring, &rccs);
+ parse_init_cd(opts.eval_rccstring, &rccs, &rccs_mpfr, mpfr_flag);
free_Char_Array(opts.eval_rccstring);
}
// evaluate
- evaleq(&rccs, flow_equation);
+ if(mpfr_flag==0){
+ evaleq(&rccs, flow_equation);
+ RCC_print(rccs);
+ free_RCC(rccs);
+ }
+ else{
+ evaleq_mpfr(&rccs_mpfr, flow_equation);
+ RCC_mpfr_print(rccs_mpfr);
+ free_RCC_mpfr(rccs_mpfr);
+ }
- // print
- RCC_print(rccs);
// free memory
free_Grouped_Polynomial(flow_equation);
- free_RCC(rccs);
return(0);
}