Changing symbol string names on-the-fly

Dr. Vassilis S. Vassiliadis vsv20 at cheng.cam.ac.uk
Wed Jul 9 12:02:07 CEST 2003


Is it possible to change on-the-fly the string
names used in a symbol?

For example, I am considering programs with
several thousands of variables and wish to output
the code for the expressions in csrc-format.

The names used internally utilize the object-partitioning
of my code e.g. :
        symbol x("system[1].composition.x[2]")

The output in raw C++ form is desired to be a simple counting
scheme e.g. for the above symbol:
        "var[101]"
will be substituted.

I have tried to use an auxiliary vector list with new symbols and
then substitute the new symbols for the old, using .subs().  However,
when the number of substitutions is beyond say a couple of hundred
even a 2.5 GHz machine cannot run the problem efficiently.  I proceeded
to test further abstract examples of substitutions and found that the
.subs()
method can indeed be extremely slow (inefficient?) in general.

Without resorting to brute force outputing and replacing of strings,
I wonder if there is an elegant and economical way to do the above in GiNaC.

Vassilis.

-----------------------------------------------------------------
Dr. Vassilis S. Vassiliadis,
Lecturer,

UNIVERSITY OF CAMBRIDGE,
DEPARTMENT OF CHEMICAL ENGINEERING

Pembroke Street,
Cambridge CB2 3RA, UK.


Tel: (reception): +44 1223 334777
Fax: (departmental): +44 1223 334796

WWW: www.cheng.cam.ac.uk/~vsv20
e-mail: vsv20 at cheng.cam.ac.uk

-----------------------------------------------------------------




More information about the GiNaC-list mailing list