[GiNaC-list] Disabling flattening of sums and products?

Martin Sandve Alnæs martinal at simula.no
Wed Nov 14 14:38:44 CET 2007

Is it possible to disable the automatic flattening of expressions like
f = (x+y) + (x+y)
g = 2*y+2*x

In other words, I want to be able to retain the additions in
expression f as binary operators. The reason for this is that I want
to examine some expression to detect subtrees that occur multiple
times, and this automatic flattening destroys some opportunities for
this. Example:

a = x*y
b = (x*y) * (x*y)

Examining a I will see a mul with ops x,y, while examining b I will
see a mul with ops power(y,2), power(x,2), requiring some kind of
factorization to recognize the similarities.


More information about the GiNaC-list mailing list