Archiving of expressions

Christian Bauer cbauer at ThEP.Physik.Uni-Mainz.DE
Wed Jan 19 21:18:43 CET 2000


Hi!

The long-awaited archiving (aka I/O) of expressions is now implemented in
the latest CVS version (except for the classes idx and structure and all
classes derived from idx and indexed, because these seem still to be
undergoing changes).

A new chapter in the tutorial explains how to use the new features.

There is now a global registry (implemented in registrar.*) for all
archivable classes (= basic and derived classes). To implement archiving
for you classes, do the following:

 - add the GINAC_DECLARE_REGISTERED_CLASS(foo, bar) line to the beginning
   of the class declaration
 - add the GINAC_IMPLEMENT_REGISTERED_CLASS(foo, bar) line to the
   beginning of the *.cpp file of the class
 - implement the unarchiving constructor and the archive() and unarchive()
   member functions in your class

If your class doesn't add any member variables to its superclass which
have to be stored in the archive, you must at least call the unarchiving
constructor and the archive() function of the superclass (see add.cpp for
an example of how to do this minimal implementation of archiving).

If you _do_ have member variables which need to be stored, they have to
be added to the archive_node in the archive() function and retrieved from
there in the unarchiving constructor (see power.cpp for a simple example,
matrix.cpp for a more complex one). The unarchive() function is almost
always the same in all classes (for exceptions, see symbol.cpp and
constant.cpp).

Unarchiving of constants is currently sub-optimal. Only the three
constants that we provide (Pi, Catalan, EulerGamma) can be unarchived.
A global registry for all existing constants should be implemented.

Also, archiving floating-point numbers will lose precision (because they
are stored as a decimal fraction). This is being worked on.

The small program "viewgar" in the tools directory is a stand-alone viewer
for archive files.

Bye,
Christian

-- 
  / Coding on PowerPC and proud of it
\/ http://www.uni-mainz.de/~bauec002/




More information about the GiNaC-devel mailing list