[GiNaC-list] parser and subs problem
Felipe Bordeu
felipe.bordeu at ec-nantes.fr
Tue Jun 29 17:55:35 CEST 2010
Hello,
I'm trying to use the ginac parser, but doesn't work as expected.
Page 81 of GiNaC 1.5.7 (an open framework ...) tutorial (29 march 2010)
" It’s also possible to map input (sub)strings to arbitrary expressions:
GiNaC::symbol x, y;
GiNaC::symtab table;
table["x"] = x+log(y)+1;
GiNaC::parser reader(table);
GiNaC::ex e = reader("5*x^3 - x^2");
"
but I get the error
terminate called after throwing an instance of 'std::invalid_argument'
what(): find_or_insert_symbol: name "x" does not correspond to a symbol
Abandon
function find_or_insert_symbol in file ginac/parser/parse_context.cpp:49
can handle only symbols not expressions.
So I tried to use only symbols and then do some subs to get the correct
expression without success.
GiNaC::symbol x, y;
GiNaC::ex expr1 = x*y;
GiNaC::ex mat1 = GiNaC::symbolic_matrix(2, 2, "K");
GiNaC::ex mat2 = GiNaC::symbolic_matrix(2, 2, "T");
GiNaC::ex expr2 = expr1.subs(GiNaC::lst(x==mat1,y==mat2));
cout << expr2 << endl;
cout << expr2.evalm() << endl;
and I get the error :
[[K00,K01],[K10,K11]]*[[T00,T01],[T10,T11]]
terminate called after throwing an instance of 'std::runtime_error'
what(): matrix::mul_scalar(): non-commutative scalar
Abandon
do I have to use indexed objects to get the correct answer???
Thanks
--
Felipe
More information about the GiNaC-list
mailing list