[GiNaC-list] problem with function pow

Saurav Pathak saurav at sas.upenn.edu
Tue Jan 31 02:39:46 CET 2006




Anish Muttreja [Mon, Jan 30, 2006 at 07:56:32PM -0500]:

+  Isn't the function called "power"? 
+  http://www.ginac.de/reference/classGiNaC_1_1power.html

hi ashish,

there is a wrapper function called "pow".  i have been able to
use the following without any problem:

        ex e3 = pow(x,2);

it seems if "pow" is in a string, it does not work.

saurav




+  On Mon, Jan 30, 2006 at 07:31:20PM -0500, Saurav Pathak wrote:
+  >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
+  >_______________________________________________
+  >GiNaC-list mailing list
+  >GiNaC-list at ginac.de
+  >https://www.cebix.net/mailman/listinfo/ginac-list

-- 
saurav


More information about the GiNaC-list mailing list