27 auto const wide_order = std::count(state.begin(), state.end(),
'\'');
28 assert(wide_order >= 0 && wide_order <= std::numeric_limits<int>::max());
29 order =
static_cast<int>(wide_order);
33 if (
order == 0 || state.empty()) {
34 throw std::runtime_error(
"Invalid equation, no prime on rhs? " + equation);
39 std::string state,
rhs;
52 std::istringstream in(
rhs);
55 DiffeqParser parser(scanner, eq_context);
65 std::string state,
rhs;
68 std::string method =
"cnexp";
static void parse_equation(const std::string &equation, std::string &state, std::string &rhs, int &order)
parse given equation into lhs, rhs and find it's order and state variable
static std::string solve_equation(std::string &state, int order, std::string &rhs, std::string &method, bool &cnexp_possible, bool debug=false)
static std::string solve(const std::string &equation, std::string method, bool debug=false)
solve equation using provided method
static bool cnexp_possible(const std::string &equation, std::string &solution)
check if given equation can be solved using cnexp method
Represent Lexer/Scanner class for differential equation parsing.
Helper class used by driver and parser while solving diff equation.
void print() const
print the context (for debugging)
std::string get_solution(bool &cnexp_possible)
return solution of the differential equation
static double order(void *v)
static std::string remove_character(std::string text, const char c)
Remove all occurrences of a given character in a text.
static std::string trim(std::string text)
static std::vector< std::string > split_string(const std::string &text, char delimiter)
Split a text in a list of words, using a given delimiter character.
encapsulates code generation backend implementations
Implement string manipulation functions.