[GiNaC-list] print_csrc, print_csrc_double... how to use?

Sheplyakov Alexei varg at theor.jinr.ru
Mon Jul 25 12:22:09 CEST 2005

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 at 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 at xxx nla-ginac]$ g++ print.cpp -lginac -lcln
> >[xxx at 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,

ROOT: an octopus made by nailing extra legs onto a cat.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-list/attachments/20050725/aba3e48b/attachment.pgp

More information about the GiNaC-list mailing list