| 8500 | |
| 8501 | template <typename T> |
| 8502 | bool run_test19() |
| 8503 | { |
| 8504 | typedef exprtk::symbol_table<T> symbol_table_t; |
| 8505 | typedef exprtk::expression<T> expression_t; |
| 8506 | typedef exprtk::parser<T> parser_t; |
| 8507 | typedef exprtk::function_compositor<T> compositor_t; |
| 8508 | typedef typename compositor_t::function function_t; |
| 8509 | |
| 8510 | { |
| 8511 | T x = T(123.123); |
| 8512 | |
| 8513 | compositor_t compositor; |
| 8514 | |
| 8515 | // f(x) = x + 2 |
| 8516 | compositor.add(function_t("f", "x + 2", "x")); |
| 8517 | |
| 8518 | // g(x) = x^2-3 |
| 8519 | compositor.add(function_t("g", "x^2 - 3", "x")); |
| 8520 | |
| 8521 | // fof(x) = f(f(x)) |
| 8522 | compositor.add(function_t("fof", "f(f(x))", "x")); |
| 8523 | |
| 8524 | // gog(x) = g(g(x)) |
| 8525 | compositor.add(function_t("gog", "g(g(x))", "x")); |
| 8526 | |
| 8527 | // fog(x) = f(g(x)) |
| 8528 | compositor.add(function_t("fog", "f(g(x))", "x")); |
| 8529 | |
| 8530 | // gof(x) = g(f(x)) |
| 8531 | compositor.add(function_t("gof", "g(f(x))", "x")); |
| 8532 | |
| 8533 | // fogof(x) = f(g(f(x))) |
| 8534 | compositor.add(function_t("fogof", "f(g(f(x)))", "x")); |
| 8535 | |
| 8536 | // gofog(x) = g(f(g(x))) |
| 8537 | compositor.add(function_t("gofog", "g(f(g(x)))", "x")); |
| 8538 | |
| 8539 | symbol_table_t& symbol_table = compositor.symbol_table(); |
| 8540 | symbol_table.add_constants(); |
| 8541 | symbol_table.add_variable("x", x); |
| 8542 | |
| 8543 | static const std::string expr_str_list[] = |
| 8544 | { |
| 8545 | "equal(f(x),(x + 2))", |
| 8546 | "equal(g(x),(x^2 - 3))", |
| 8547 | "equal(fof(x),(x + 4))", |
| 8548 | "equal(gog(x),(x^4 - 6x^2 + 6))", |
| 8549 | "equal(fog(x),(x^2 - 1))", |
| 8550 | "equal(gof(x),(x^2 + 4x + 1))", |
| 8551 | "equal(fogof(x),(x^2 + 4x + 3))", |
| 8552 | "equal(gofog(x),(x^4 - 2x^2 - 2))" |
| 8553 | }; |
| 8554 | static const std::size_t expr_str_list_size = sizeof(expr_str_list) / sizeof(std::string); |
| 8555 | |
| 8556 | std::deque<expression_t> expression_list; |
| 8557 | |
| 8558 | for (std::size_t i = 0; i < expr_str_list_size; ++i) |
| 8559 | { |