[GiNaC-list] problem with function pow
Saurav Pathak
saurav at sas.upenn.edu
Tue Feb 7 22:13:01 CET 2006
I am resending this mail. This is a very critical issue for me.
I absolutely must be able to change a string into an expression.
And if I am doing it wrong, please show it to me.
Thanks,
Saurav
Saurav Pathak [Mon, Jan 30, 2006 at 07:31:20PM -0500]:
+ hi,
+
+ i am having trouble turning a string with function "pow" into an
+ expression. an example of the code is given below along with the
+ output. i cannot figure out what i am doing wrong.
+
+ thanks for your help in advance.
+ --------
+ #include <iostream>
+ #include <string>
+ #include <ginac/ginac.h>
+ #include <ginac/power.h>
+ using namespace std;
+ using namespace GiNaC;
+
+ int main()
+ {
+ lst all;
+ all.append(symbol("x"));
+
+ // no pow
+ string str2 = "x*x";
+ ex e2(str2, all);
+ cout << "nopow : " << e2 << endl;
+
+ // with pow
+ string str = "pow(x, 2)";
+ ex e(str, all);
+ cout << "withpow: " << e << endl;
+
+ return 0;
+ }
+
+ the output is:
+ nopow : x^2
+ terminate called after throwing an instance of 'std::runtime_error'
+ what(): no function 'pow' with 2 parameters defined
+ Aborted
+ --------------------
+ --
+ saurav
More information about the GiNaC-list
mailing list