PyGiNaC is a Python package that provides an interface to the C++ library GiNaC, which is an open framework for symbolic computation within C++. PyGiNaC is implemented with the help of the Boost.Python library. At the moment, the package is more or less in an "alpha" state, i.e. the GiNaC classes are only partially exposed, parts of regression test suite are unconverted and no actual documentation exists. However, all of this is supposed to change in the future.
The current implementation of PyGiNaC has, up to our knowledge, two predecessors: a version written by Pearu Peterson some years ago, and another one by Ondrej Certik.
Despite of being not-so-complete, PyGiNaC can do some fancy stuff for you. For example, solving a linear system of equations in the Python intepreter can be as simple as
>>> x = symbol('x') >>> y = symbol('y') >>> lsolve([3*x + 5*y == 2, 5*x+y == -3], [x,y]) [<cginac.relational object at 0xb7de61bc>, <cginac.relational object at 0xb7de648c>] >>> [str(x) for x in lsolve([3*x + 5*y == 2, 5*x+y == -3], [x,y])] ['x==-17/22', 'y==19/22'] >>>
Power series of functions are also handled
>>> x = symbol('x') >>> print sin(x).series(x==0, 8) 1*x+(-1/6)*x**3+1/120*x**5+(-1/5040)*x**7+Order(x**8) >>>
Or try a modified version of one of Ramanujan's identities (this example is ripped off from GiNaC's regression test suite)
>>> e1 = pow(1 + pow(3,numeric(1,5)) - pow(3,numeric(2,5)),3) >>> e2 = expand(e1 - 10 + 5*pow(3,numeric(3,5))) >>> print e2.expand() 0 >>>Above numeric(3,5) is a fraction 3/5.
At the moment there are no released tarballs of PyGiNaC. Instead, it can be downloaded directly from the CVS repository at SourceForge. To do a CVS checkout, issue the following commands
cvs -d:pserver:firstname.lastname@example.org:/cvsroot/pyginac login cvs -z3 -d:pserver:email@example.com:/cvsroot/pyginac co -P pyginacOr, you can, of course, browse the CVS.
To run PyGiNaC you need to have the following software installed:
In addition to the above, to compile PyGiNaC the following are needed
Once you have all the dependencies listed above installed, issue the command "scons". This will build the module in-place. An install target is not yet supported. Instead, the script "run" can be used to start an interactive Python session that will be able to use PyGiNaC by
$ ./run python2.3or, to run a Python script
$ ./run python2.3 some_script_file.py
That's it. Have fun. :) In case of any trouble, see the mailing list below.
There is a single PyGiNaC mailing list, pyginac-users(at)lists.sourceforge.net. Since there are not separate development and/or bug reporting lists, any kind of discussion related to PyGiNaC is welcome, including suggestions and bug reports. There are also archives to browse.
The following are ongoing projects.
PyGiNaC is originally written by Jonathan Brandmeyer and later co-authored by Matti Peltomäki. Patches have been submitted by Ondrej Certik.
Some more information can also be found on the SF.net project page.