[GiNaC-list] arithmetic error on concat two expressions

Kraus Philipp philipp.kraus at flashpixx.de
Fri Aug 6 12:03:11 CEST 2010


Hi,

I'm new at GiNaC and I use the lib for create a gradient descent  
algorithm (symbolic calculating).
I have a formula "a*x^3+b*y^4" and I subsitute the formula in the  
error function "0.5*(t - <formula>)^2".
After the substitution GiNaC returns the expression  
"(0.5)*(a*x^3+b*y^4-t)^2".

I use this code:
GiNaC::ex m_expression;
GiNaC::symtab m_exprtable;

try {
	m_expression = l_parser( "a*x^3+b*y^4" );
         m_exprtable  = l_parser.get_syms();
} catch (...) {}


GiNaC::ex l_full;
GiNaC::symtab l_table(m_exprtable);

l_table["formula"] = m_expression;
GiNaC::parser l_parser(l_table);

try {
	l_full      = l_parser( "0.5*(t - formula)^2" ); // (*)
} catch (...) {}

std::cout << l_full << std::endl;


I using the version 1.5.8 (on 1.5.7 I had got a compiler error).

Is this the correct way for concating two symbolic expression?
Do I have forgot anything?

Thanks

Phil

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cebix.net/pipermail/ginac-list/attachments/20100806/b4667ef9/attachment.html>


More information about the GiNaC-list mailing list