On Mon, Jul 25, 2005 at 05:47:44PM +1000, John Pye wrote:
Probably a silly question here. I'm trying to work out how to use the 'print_csrc' functionality in GiNaC. I don't seem to be able to make it work. Please could someone offer me some suggestions on how to fix the following?
[xxx@xxx nla-ginac]$ cat print.cpp #include <ginac/ginac.h> #include <iostream>
using namespace GiNaC;
int main(){ symbol x("x"); ex f = log(pow(x,2)); print_csrc(std::cout); std::cout << f << std::endl; }
[xxx@xxx nla-ginac]$ g++ print.cpp -lginac -lcln [xxx@xxx nla-ginac]$ ./a.out *log(x^2)*
Notice that it's outputing 'x^2' and not 'pow(x,2)' or 'x*x'. It seems that the print_csrc call isn't doing anything.
I don't think so. This call creates temporary object of `print_csrc' type. However, this object is never used in the subsequent code.
What am I doing wrong?
You are using default output format (instead of `csrc'). Use this instead: std::cout << csrc << f << std::endl << dflt; [re-]read GiNaC documentation (in particular, the chapter about input/output) for more details. Best regards, Alexei -- ROOT: an octopus made by nailing extra legs onto a cat.