[GiNaC-list] list input

soppon gvitbsord at aol.com
Sun Mar 1 12:25:17 CET 2015

On 03/01/2015 05:53 AM, Richard B. Kreckel wrote:
> On 03/01/2015 11:38 AM, soppon wrote:
>> Hi. I'm trying to use list as input. List as output prints
>> {expr1,expr2,..}, list.nops() is varying.
>> When I write list as:
>> parser reader;
>> somelist=reader(cin);
>> where input to cin: {expr1,expr2,..} at the end shift-D
>> It returns somelist={expr1,expr2,..}, somelist.nops()=1.  When accessing
>> the 2nd and higher
>> element of list, program gets segmentation fault.
> Please do provide a minimal sample program when reporting bugs. Thanks.
>    -richard.
#include <iostream>
#include <ginac/ginac.h>
using namespace std;
using namespace GiNaC;

int main()
     symbol xs("x");
     lst expr;
     parser reader;
     cout <<"list " << expr  << endl;
     cout <<"number of elements "<< expr.nops() << endl;
     cout <<"1st el " <<expr[0] << endl;
     cout <<"2nd el, error " <<expr[1]<< endl;
     return 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list_input.cpp
Type: text/x-c++src
Size: 356 bytes
Desc: not available
URL: <http://www.cebix.net/pipermail/ginac-list/attachments/20150301/854fa863/attachment.cpp>

More information about the GiNaC-list mailing list