/* 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_deriv.h" #include #include #include "parse_file.h" #include "cli_parser.h" #include "istring.h" #include "definitions.cpp" #include "array.h" #include "grouped_polynomial.h" #define CP_FLAG_DERIVS 1 #define CP_FLAG_VARS 2 // read command line arguments int tool_deriv_read_args(int argc, const char* argv[], Str_Array* str_args, Meantools_Options* opts){ // 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; // buffer in which to read the variables Char_Array buffer; int i; char* ptr; // defaults // differentiate once (*opts).deriv_derivs=1; // differentiate with respect to all variables (*opts).deriv_vars.length=-1; // do not chain (*opts).chain=0; // loop over arguments for(i=2;i=0){ int_array_read(str_args.strs[arg_index],&(opts.deriv_vars)); } } } // if variables length is negative then set the variables to all of the available ones if(opts.deriv_vars.length<0){ init_Int_Array(&(opts.deriv_vars), flow_equation.length); for(i=0;i=0){ int_array_append((j+1)*DOFFSET+variables.values[i], &indices); } // constants have a negative index else{ int_array_append(-(j+1)*DOFFSET+variables.values[i], &indices); } } // add to flow equation grouped_polynomial_concat(dflow, flow_equation_derivs); } if(n>0){ free_Grouped_Polynomial(dflow); } free_Int_Array(indices); return(0); }