14namespace layer1_foundations {
15namespace expression_parser {
48 cout <<
"degree=" <<
degree << endl;
53 std::string &managed_variables, std::string &formula_text,
56 int f_v = (verbose_level >= 1);
59 cout <<
"formula::init" << endl;
90 cout <<
"formula::initadding managed variable " << var << endl;
102 cout <<
"formula::initManaged variables: " << endl;
114 cout <<
"formula::initParsing " <<
name_of_formula <<
" finished" << endl;
119 cout <<
"formula::initSyntax tree:" << endl;
128 std::ofstream ost(fname);
133 cout <<
"formula::init before tree->is_homogeneous" << endl;
137 cout <<
"formula::init after tree->is_homogeneous" << endl;
141 cout <<
"formula::init the formula is homogeneous of degree " <<
degree << endl;
145 cout <<
"formula::init done" << endl;
154 int f_v = (verbose_level >= 1);
157 cout <<
"formula::get_subtrees" << endl;
161 cout <<
"formula::get_subtrees !f_is_homogeneous" << endl;
167 cout <<
"homogeneous of degree " <<
degree << endl;
171 cout <<
"formula::get_subtrees degree != Poly->degree" << endl;
182 if (Descr->f_evaluate) {
184 cout <<
"before evaluate" << endl;
186 const char *p = Descr->evaluate_text.c_str();
189 std::map<std::string, std::string> symbol_table;
194 if (!s_scan_token_comma_separated(&p, str)) {
200 assignment.assign(str);
205 found = assignment.find(
'=');
206 if (found == std::string::npos) {
207 cout <<
"did not find '=' in variable assignment" << endl;
210 std::string symb = assignment.substr (0, found);
211 std::string val = assignment.substr (found + 1, len - found - 1);
215 cout <<
"adding symbol " << symb <<
" = " << val << endl;
217 symbol_table[symb] = val;
224 cout <<
"symbol table:" << endl;
225 for (i = 0; i < symbol_table.size(); i++) {
226 cout << i <<
" : " << symbol_table[i] <<
" = " << values[i] << endl;
232 Values =
NEW_int(nb_monomials);
234 for (i = 0; i < nb_monomials; i++) {
235 cout <<
"Monomial " << i <<
" : ";
238 a = Subtrees[i]->
evaluate(symbol_table, F, verbose_level);
245 cout <<
"no subtree" << endl;
249 cout <<
"evaluated polynomial:" << endl;
250 for (i = 0; i < nb_monomials; i++) {
251 cout << Values[i] <<
" * ";
255 cout <<
"coefficient vector: ";
256 int_vec_print(cout, Values, nb_monomials);
264 cout <<
"formula::get_subtrees done" << endl;
272 int f_v = (verbose_level >= 1);
275 cout <<
"formula::evaluate" << endl;
279 const char *p = evaluate_text.c_str();
282 std::map<std::string, std::string> symbol_table;
293 assignment.assign(str);
298 found = assignment.find(
'=');
299 if (found == std::string::npos) {
300 cout <<
"did not find '=' in variable assignment" << endl;
303 std::string symb = assignment.substr (0, found);
304 std::string val = assignment.substr (found + 1, len - found - 1);
308 cout <<
"adding symbol " << symb <<
" = " << val << endl;
310 symbol_table[symb] = val;
317 cout <<
"symbol table:" << endl;
318 for (i = 0; i < symbol_table.size(); i++) {
319 cout << i <<
" : " << symbol_table[i] <<
" = " << values[i] << endl;
327 cout <<
"Monomial " << i <<
" : ";
330 a = Subtrees[i]->
evaluate(symbol_table, Poly->
get_F(), verbose_level);
337 cout <<
"no subtree" << endl;
341 cout <<
"evaluated polynomial:" << endl;
343 cout << Values[i] <<
" * ";
347 cout <<
"coefficient vector: ";
353 cout <<
"formula::evaluate done" << endl;
class to parse expressions
interior node in a syntax tree
int evaluate(std::map< std::string, std::string > &symbol_table, field_theory::finite_field *F, int verbose_level)
void export_graphviz(std::string &name, std::ostream &ost)
the syntax tree of an expression
void split_by_monomials(ring_theory::homogeneous_polynomial_domain *Poly, syntax_tree_node **&Subtrees, int verbose_level)
int is_homogeneous(int °ree, int verbose_level)
std::vector< std::string > managed_variables
int f_has_managed_variables
void print(std::ostream &ost)
homogeneous polynomials of a given degree in a given number of variables over a finite field GF(q)
void print_monomial(std::ostream &ost, int i)
field_theory::finite_field * get_F()
#define Int_vec_print(A, B, C)
the orbiter library for the classification of combinatorial objects