The following code produces an error that says that it should be reported : #include<ginac/ginac.h> #include<iostream> int main(int argc, char* argv[]) { GiNaC::symtab table; table["x"] = 2.34; GiNaC::parser p(table); GiNaC::ex e = p("2*cos(x)+e^x"); GiNaC::numeric n = GiNaC::ex_to<GiNaC::numeric>(e); double x = GiNaC::ex_to<GiNaC::numeric>(n.evalf()).to_double(); std::cout << x << std::endl; return 0; } The error : terminate called after throwing an instance of 'cln::notreached_exception' what(): Internal error: statement in file real/elem/cl_R_mul.cc, line 93 has been reached!! Please send the authors of the program a description how you produced this error! Best Jean-Michaël
Hi,
On Mon, 13 Mar 2017 23:42:12 +0100, Jean-Michaël Celerier <jeanmichael.celerier@gmail.com> said:
GiNaC::ex e = p("2*cos(x)+e^x"); This conversion leaves e^x to be "a symbol e to power x", where e is GiNaC::symbol and is not the base of natural logarithms. This cannot be converted to a double and produces the quoted error. The following (simpler) code produces the correct answer: #include<ginac/ginac.h> #include<iostream> int main(int argc, char* argv[]) { GiNaC::symtab table; table["x"] = 2.34; GiNaC::parser p(table); GiNaC::ex e = p("2*cos(x)+exp(x)"); GiNaC::numeric n = GiNaC::ex_to<GiNaC::numeric>(e); double x = n.to_double(); std::cout << x << std::endl; return 0; } Best wishes, Vladimir -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/
participants (2)
-
Jean-Michaël Celerier
-
Vladimir V. Kisil