On Jun 18, 9:13 am, "Ondrej Certik" <[EMAIL PROTECTED]> wrote:
> On Wed, Jun 18, 2008 at 11:03 AM, Pearu Peterson
>
> <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > In sympycore we have Verbatim class that holds expressions without
> > any evaluation. E.g. it can hold the expression 'x - y' in both
> > forms: Add(x, -y) and Sub(x, y). Converting to Verbatim and back
> > to the default representation is relatively cheap. May sympy should
> > implement a similar scheme in order to better support the cse
> > algorithm.
>
> Thanks for the tip. BTW, you don't seem to have a class Sub in
> sympycore, definitely not exported by default.
sympycore does not have classes Add, Mul, et as well:)
However, Sub is not exposed indeed (may be it should),
it is available as class method to ring algebras:
>>> Calculus.Sub(x, y)
Calculus('x - y')
>>> Calculus.Add(x, y)
Calculus('x + y')
Anyway, here's how Verbatim can be used in sympycore (the interface
has room for improvement, of course):
>>> from sympycore import *
>>> from sympycore.utils import SUB, ADD
>>> x,y,z,v,w=map(Symbol,'xyzvw')
>>> Verbatim(SUB, (x,y))
Verbatim('x - y')
>>> Verbatim(ADD, (x,-y))
Verbatim('x + -y')
>>> print Verbatim(SUB, (x,y)).as_tree()
Verbatim:
SUB[
SYMBOL[x]
SYMBOL[y]
]
Pearu
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---