[GiNaC-list] How to put variables to the second argument of ex::ex()

Shi mm at shiros.net
Sun Nov 16 07:53:28 CET 2014


Hello,
I'd like to convert std::string to ex constructor.
But my code do not work now.
How to put variables to the second argument of 
ex(const std::string &s, const ex &l).

----Code:

#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;

int main(){
   string st("2*a+3*sqrt(4)*b");
   symbol a("a"), b("b");
   ex sample(st, ex(a));
   cout << sample <<endl;
   return 0;
}

----Excuted:

terminate called after throwing an instance of
'std::invalid_argument'
  what():  find_or_insert_symbol: symbol "a" not found
IOT trap



More information about the GiNaC-list mailing list