/* Copyright 2015-2022 Ian Jauslin Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "meantools_eval.h" #include #include #include #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 int exists_file=0; // flag int flag=0; int i; char* ptr; // 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=0){ char_array_cpy(str_args.strs[arg_index],&(opts.eval_rccstring)); } } } // initialize the 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, &rccs_mpfr, mpfr_flag); free_Char_Array(opts.eval_rccstring); } // evaluate if(mpfr_flag==0){ evaleq(rccs, rccs, flow_equation); RCC_print(rccs); free_RCC(rccs); } else{ evaleq_mpfr(rccs_mpfr, rccs_mpfr, flow_equation); RCC_mpfr_print(rccs_mpfr); free_RCC_mpfr(rccs_mpfr); } // free memory free_Grouped_Polynomial(flow_equation); return(0); }