[GiNaC-devel] GiNaC is not a C compiler [Was: Optimized C-style output]

Richard B. Kreckel kreckel at ginac.de
Tue Mar 27 22:29:20 CEST 2007


Dear Stefan,

Stefan Weinzierl wrote:
> thinking about it, we probably want the following: a data structure
> consisting of two lists,
>  lhs = lst(t0,t1,...)
>  rhs = lst(expr0,expr1,...)
> with the understanding that this should represent something like
>  ...
>  t1 = expr1;
>  t0 = expr0;
> 
> There is a consistency condition which needs to be fulfilled: The right
> hand side of the (j+1)-th entry cannot refer to symbols t0,...,tj, which
> would be defined later.
> 
> One can consider two such structures equivalent, if the values of
> t0,...,tn would be the same after execution of the corresponding code
> fragments. In most cases we are just interested in n=0.
> This is actually an equivalence relation in the mathematical sense.
> 
> For this structure we can have methods, which transform the structure into
> an equivalent one.
> These methods can add or remove entries from the two lists, or change the
> order.
> Methods, which just transform the rhs are in some sense trivial and not
> considered here.
> 
> Examples of such methods could be:
>  - replace common subexpressions of type T1, T2, ...  in the rhs.
>  - split containers with more than n_max arguments
>  - (eliminate redundant variables)
> 
> This structure has then a print method, which simply prints
>  ...
>  double t1 = expr1;
>  double t0 = expr0;
> 
> Everybody happy with this concept ?

It seems to make a lot of sense but I am not entirely sure if I 
understand the proposal correctly. Could you, please, add a small 
mock-up snippet of user code where at least two nontrivial expressions 
are "optimized" in this sense in order to make things clear?

TIA
   -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>



More information about the GiNaC-devel mailing list