[GiNaC-list] Converting an expression to std::string and back again
rhey at gmx.de
Tue Mar 28 09:57:20 CEST 2017
Dear Mailing List,
for a project I need to convert a std::string to an ex, diff it and then convert it back to a std::string. For the conversion from std::string to ex I found this constructor :
/** Construct example from string and a list of symbols. The input grammar is * similar to the GiNaC
output format. All symbols and indices to be used * in the expression must be specified in a lst in the
second argument. * Undefined symbols and other parser errors will throw an exception. */
ex(const std::string &s, const ex &l);
So I tried doing the following :
std::cout << diff(e,x) << std::endl;
But this leads me to this exception :
std::invalid_argument: find_or_insert_symbol: symbol "x" not found
Note that I tried using expression and e in diff(e,x). Unfortunately I could not find any documentation on how to convert the expression diff returns to a std::string.
Thanks a lot for your help in advance !
More information about the GiNaC-list