[sympy] Re: converting exponentiation to use pow in tostr

2008-09-30 Thread Vinzent Steinberg
There is a similar function already available in sympy/utilities/ compilef.py (which generates C code and compiles it dynamically using libtcc). It's called cexpr and works with strings. But the implementation is so much uglier. :) Vinzent On Sep 30, 11:08 am, "Ondrej Certik" <[EMAIL PROTECTED]>

[sympy] Re: converting exponentiation to use pow in tostr

2008-09-30 Thread Ondrej Certik
On Tue, Sep 30, 2008 at 9:51 AM, Andy Ray Terrel <[EMAIL PROTECTED]> wrote: > > On Tue, Sep 30, 2008 at 12:11 AM, Ondrej Certik <[EMAIL PROTECTED]> wrote: >> >> On Mon, Sep 29, 2008 at 11:40 PM, Andy R. Terrel <[EMAIL PROTECTED]> wrote: >>> >>> Hmm updated my ancient code and got this to work: >>>

[sympy] Re: converting exponentiation to use pow in tostr

2008-09-30 Thread Andy Ray Terrel
On Tue, Sep 30, 2008 at 12:11 AM, Ondrej Certik <[EMAIL PROTECTED]> wrote: > > On Mon, Sep 29, 2008 at 11:40 PM, Andy R. Terrel <[EMAIL PROTECTED]> wrote: >> >> Hmm updated my ancient code and got this to work: >> >> class CppPrinter(printing.str.StrPrinter): >>def _print_Pow(self, expr): >>

[sympy] Re: converting exponentiation to use pow in tostr

2008-09-29 Thread Ondrej Certik
On Mon, Sep 29, 2008 at 11:40 PM, Andy R. Terrel <[EMAIL PROTECTED]> wrote: > > Hmm updated my ancient code and got this to work: > > class CppPrinter(printing.str.StrPrinter): >def _print_Pow(self, expr): >PREC = printing.precedence.precedence(expr) >if expr.exp is S.NegativeO

[sympy] Re: converting exponentiation to use pow in tostr

2008-09-29 Thread Andy R. Terrel
Hmm updated my ancient code and got this to work: class CppPrinter(printing.str.StrPrinter): def _print_Pow(self, expr): PREC = printing.precedence.precedence(expr) if expr.exp is S.NegativeOne: return '1/%s'%(self.parenthesize(expr.base, PREC)) else: