[GiNaC-list] Example Input Program Hanging Up

Casey Conger CaConger at physics.ucsd.edu
Mon Jan 27 11:19:48 CET 2014

Hello all,

	I’m having trouble with running the example interactive program from the tutorial.  I simply cut and pasted it, but after it asks for “an expression involving ‘x’ “ it just hangs and never does anything.  The problem seems to be in the line  ‘ex e = reader(cin)’, I got the other examples to run just fine, but the reader(cin) seems to be problematic.

My setup: Macbook Air1.5GHZ i7, OSX 10.9.1, ginac 1.6.2

My program:

#include <iostream>
#include <string>
#include <stdexcept>
#include <ginac/ginac.h>
    using namespace std;
    using namespace GiNaC;
    int main()
        cout << "Enter an expression containing ’x’: " << flush;
        parser reader;
        try {
            ex e = reader(cin);
            symtab table = reader.get_syms();
            symbol x = table.find("x") != table.end() ?
            ex_to<symbol>(table["x"]) : symbol("x");
            cout << "The derivative of " << e << " with respect to x is ";
            cout << e.diff(x) << "." << endl;
        } catch (exception &p) {
            cerr << p.what() << endl;


Caseys-MacBook-Air:ginac casey$ g++ ginacPlay.cpp -o ginacPlay.out -lginac -lcln 
Caseys-MacBook-Air:ginac casey$ ./ginacPlay.out 
Enter an expression containing ’x’: x
…It just hangs there for several minutes.

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

More information about the GiNaC-list mailing list