Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/numkondo.c')
-rw-r--r--src/numkondo.c80
1 files changed, 61 insertions, 19 deletions
diff --git a/src/numkondo.c b/src/numkondo.c
index dce7de6..0568861 100644
--- a/src/numkondo.c
+++ b/src/numkondo.c
@@ -30,6 +30,7 @@ Compute the flow of a flow equation numerically
// rccs
#include "rcc.h"
+#include "rcc_mpfr.h"
// grouped representation of polynomials
#include "grouped_polynomial.h"
// command line parser
@@ -38,6 +39,7 @@ Compute the flow of a flow equation numerically
#include "parse_file.h"
// numerical flow
#include "flow.h"
+#include "flow_mpfr.h"
// arrays
#include "array.h"
@@ -68,10 +70,13 @@ int main (int argc, const char* argv[]){
// parse command-line arguments
#define CP_FLAG_NITER 1
-#define CP_FLAG_TOL 2
-#define CP_FLAG_RCCS 3
+#define CP_FLAG_RCCS 2
+#define CP_FLAG_MPFR_PREC 3
+#define CP_FLAG_MPFR_EXP 4
int read_args_numkondo(int argc,const char* argv[], Str_Array* str_args, Numkondo_Options* opts){
int i;
+ // temporary long int
+ long int tmp_lint;
// pointers
char* ptr;
// file to read the polynomial from in flow mode
@@ -92,10 +97,11 @@ int read_args_numkondo(int argc,const char* argv[], Str_Array* str_args, Numkond
(*opts).display_mode=DISPLAY_NUMERICAL;
// default niter
(*opts).niter=100;
- // default to 0 tolerance
- (*opts).tol=0;
// 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=1;i<argc;i++){
@@ -111,14 +117,18 @@ for(i=1;i<argc;i++){
case 'N':
flag=CP_FLAG_NITER;
break;
- // tolerance
- case 'D':
- flag=CP_FLAG_TOL;
- break;
// initial condition
case 'I':
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;
// print version
case 'v':
printf("numkondo " VERSION "\n");
@@ -134,16 +144,23 @@ for(i=1;i<argc;i++){
// reset flag
flag=0;
}
- // tolerance
- else if (flag==CP_FLAG_TOL){
- sscanf(argv[i],"%Lf",&((*opts).tol));
- flag=0;
- }
// init condition
else if(flag==CP_FLAG_RCCS){
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];
@@ -158,7 +175,7 @@ for(i=1;i<argc;i++){
// print usage message
int print_usage_numkondo(){
- printf("\nusage:\n numkondo [-F] [-N niter] [-D tolerance] [-I initial_condition] <filename>\n\n");
+ printf("\nusage:\n numkondo [-F] [-N niter] [-I initial_condition] [-P precision] [-E exponent_range] <filename>\n\n");
return(0);
}
@@ -171,8 +188,22 @@ int numflow(Str_Array str_args, Numkondo_Options opts){
Labels labels;
// initial condition
RCC init_cd;
+ RCC_mpfr init_cd_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 id table
arg_index=find_str_arg("labels", str_args);
@@ -207,20 +238,31 @@ int numflow(Str_Array str_args, Numkondo_Options opts){
}
}
// initialize the rccs
- prepare_init(flow_equation.indices,flow_equation.length,&init_cd);
+ if(mpfr_flag==0){
+ prepare_init(flow_equation.indices,flow_equation.length,&init_cd);
+ }
+ else{
+ prepare_init_mpfr(flow_equation.indices,flow_equation.length,&init_cd_mpfr);
+ }
+
// read rccs from string
if(opts.eval_rccstring.length!=-1){
- parse_init_cd(opts.eval_rccstring, &init_cd);
+ parse_init_cd(opts.eval_rccstring, &init_cd, &init_cd_mpfr, mpfr_flag);
free_Char_Array(opts.eval_rccstring);
}
- numerical_flow(flow_equation, init_cd, labels, opts.niter, opts.tol, opts.display_mode);
+ if(mpfr_flag==0){
+ numerical_flow(flow_equation, init_cd, labels, opts.niter, opts.display_mode);
+ free_RCC(init_cd);
+ }
+ else{
+ numerical_flow_mpfr(flow_equation, init_cd_mpfr, labels, opts.niter, opts.display_mode);
+ free_RCC_mpfr(init_cd_mpfr);
+ }
- free_RCC(init_cd);
// free memory
free_Labels(labels);
free_Grouped_Polynomial(flow_equation);
return(0);
}
-