[GiNaC-list] list input

soppon gvitbsord at aol.com
Sun Mar 1 12:48:30 CET 2015

On 03/01/2015 06:01 AM, Vladimir V. Kisil wrote:
>>>>>> On Sun, 01 Mar 2015 05:38:41 -0500, soppon <gvitbsord at aol.com> said:
>      soppon> Hi. I'm trying to use list as input. List as output prints
>      soppon> {expr1,expr2,..}, list.nops() is varying.  When I write list
>      soppon> as: parser reader; somelist=reader(cin); where input to cin:
>      soppon> {expr1,expr2,..} at the end shift-D It returns
>      soppon> somelist={expr1,expr2,..}, somelist.nops()=1.  When
>      soppon> accessing the 2nd and higher element of list, program gets
>      soppon> segmentation fault.
>      I am not completely sure, but the following example may give you a
>    hint:
>    ex l1=lst(a,b,c);
>    lst l2=l1;
>    In this case l1.nops()=3, but l2.nops()=1, because l2 has the only
>    element equal to l1 as a whole. To get thing right you may use:
>    ex l1=lst(a,b,c);
>    lst l2=ex_to<lst>(l1);
>    To analyse situation use somelist.dbgprint() or even
>    somelist.dbgprinttree().
I didn't see dbgprint() in tutorial, so i use tree for debug.
#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;

int main()
     symbol xs("x");
     lst expr,ep;
     parser reader;
     cout<<expr<<tree  << endl; //get {{x,x}}
     cout<<ep<<tree  << endl; //some hash table
     return 0;

More information about the GiNaC-list mailing list