PyGiNaC ­ Python Interface to GiNaC

by Pearu Peterson

What's new?

August 24, 2001
Work-in-progress release. Version 0.6.
April 27, 2001
First pre-release. Version 0.4.

Introduction

PyGiNaC is a Python package that provides an interface to C++ library GiNaC - GiNaC is Not a CAS. GiNaC is open framework for symbolic computation within the C++ programming language. See GiNaC tutorial for more information about GiNaC capabilities and limitations.

Currently PyGiNaC exposes the following GiNaC classes to Python:

symbol
Basic CAS symbols.
numeric
Wrapper of CLN-numbers.
constant
Symbols with specific numerical value.
add, mul, power, ncmul
Arithmetic operations with symbolic objects.
matrix
Symbolic matrices. [NOT Impl.]
pseries
Extended truncated power series. [NOT Impl.]
relational
Logical relations between two expressions.
function
Symbolic functions.
lst
GiNaC native container of symbolic objects.
Other GiNaC classes such as indexed, idx, etc. will be wrapped soon.

All GiNaC's symbolic classes are exposed to Python through a light-weighted wrapper class ex.

Currently PyGiNaC lacks tutorial for Python users. But to get started, see GiNaC tutorial and doctest strings in ginac.doc.html.

Requirements

  1. Python (2.1 or later, partial support (only PyGiNaC-0.4) is available also for Python 1.5.2 and 2.0 - see notes below).
  2. GiNaC - GiNaC is Not a CAS (0.8.1 or later, PyGiNaC-0.6 requires 0.9.4). GiNaC requires
    1. CLN - Common Lisp Numbers (1.1 or later). Note that CLN optionally supports GMP (3.1.1 or later) and it is highly recommended for better performance. See Lundman's Unix Projects for MSVC port of the GMP library.
  3. Boost.Python (1.21.1 or later). For your convenience, a lite version of Boost.Python is included with the PyGiNaC package.

Download

Snapshots of the pre-release:
rel-0.x/PyGiNaC-0.latest.tar.gz

Installation

It is crucial that you first install required version of GiNaC.

To install PyGiNaC, unpack the source file, change to directory PyGiNaC-?.?.? and run python setup4.py install. To test PyGiNaC, run cd test4 && python test_all.py.

Platform/Compiler/Version Related Notes

PyGiNaC is developed on Intel Linux (Debian Potato, Redhat Mandrake 7.0) with gcc (2.95.2) compiler. If you are able to build GiNaC and CLN then there should be no problems to compile and use PyGiNaC. Target Python version is currently 2.1.

[Applies only for PyGiNaC-0.4:] PyGiNaC compiles also for Python 2.0 but be aware that due to the changes of coersion rules in Python 2.1 incorrect behaviour is expected when using it with Python 2.0. For example, multiplication a * b of symbolic objects is carried out in Python 2.0 as b.__mul__(a) (for some reasons that I don't understand). This will affect results where multiplication is non-commutative, for example, matrix multiplication. [This is fixed now for Python 2.0 and earlier, but there are no guarantees.]

[Applies only for PyGiNaC-0.4:] To compile PyGiNaC for Python 1.5, change to directory PyGiNaC-?.?.?/python1.5, run make install (if that fails, study Makefile and change it to your needs). Note that in Python 1.5 user-defined symbolic functions are not supported (but it is not impossible to use them under Python 1.5, study ginac.build_function() and try to adapt its Python 2.1 code to Python 1.5).

Mailing list

There is a mailing list pyginac open for PyGiNaC support/bug reports/suggestions. You can subscribe the list here.

CVS Repository

PyGiNaC is being developed under CVS and those who are interested in the really latest version of PyGiNaC (possibly unstable) can get it from the repository as follows:
  1. First you need to login (the password is guest):
    > cvs -d :pserver:anonymous@cens.ioc.ee:/home/cvs login
    
  2. and then do the checkout:
    > cvs -z6 -d :pserver:anonymous@cens.ioc.ee:/home/cvs checkout pyGiNaC
    
  3. In the directory pyGiNaC you can get the updates by hitting
    > cvs -z6 update -P -d
    
You can browse PyGiNaC CVS repository here.

What can You do for PyGiNaC and GiNaC?

While using PyGiNaC you'll certainly find that there are many things that can be improved and many things that are missing compared to other CAS'es. The list of PyGiNaC features depends very much on the GiNaC capabilities. So, there are two branches where you can contribute to make symbolic calculations possible in Python:
  1. Development of GiNaC and its extensions. See GiNaC homepage for more details.
  2. Development of an interface between GiNaC and Python (PyGiNaC). And Python extensions to PyGiNaC. Here is a list of tasks where volunteers are most welcome:
    Pretty-printing of symbolic expressions from Python (or better yet, from GiNaC)
    There are two tools that can be used here: 1) MINSE, 2) eqascii.
    PyGiNaC Tutorial
    ... requires someone fluent in English and damned with the Python language:-).
    ...

Related sites

  1. Bjarne Stroustrup's FAQ about C++ language.

Pearu Peterson <pearu@cens.ioc.ee>
Last modified: Fri Jan 12 16:44:25 EET 2001