bug in fcode

26 views
Skip to first unread message

Dirk Van Essendelft

unread,
Apr 20, 2015, 4:05:37 PM4/20/15
to sy...@googlegroups.com
I'm writing some code to produce some fortran and c compilable math expressions and I notices a strange thing:

if I do:

x = symbols("x")

exp(Min(2,x))

I get 'exp(Min(2,x))'

as I would expect, but if I do

fcode(exp(Min(2,x)))

I get: 'exp(Min(1.0d0, x))'

which is obviously not the right expression

If I do

ccode(exp(Min(2,x)))

I get: 'exp(Min(2,x))'

which seems correct

Ondřej Čertík

unread,
Apr 20, 2015, 4:19:23 PM4/20/15
to sympy
On Mon, Apr 20, 2015 at 1:35 PM, Dirk Van Essendelft
<dirkt...@gmail.com> wrote:
> I'm writing some code to produce some fortran and c compilable math
> expressions and I notices a strange thing:
>
> if I do:
>
> x = symbols("x")
>
> exp(Min(2,x))
>
> I get 'exp(Min(2,x))'
>
> as I would expect, but if I do
>
> fcode(exp(Min(2,x)))
>
> I get: 'exp(Min(1.0d0, x))'

This is what I get with the sympy d8b78b4625897da73dd5ae764f45adf0803747b2:

In [1]: fcode(exp(Min(2,x)))
Out[1]: ' exp(Min(2.0d0, x))'

and with sympy-0.7.5 I get:

In [1]: fcode(exp(Min(2,x)))
Out[1]: ' exp(Min(1.0d0, x))'

a quick git bisect reveals it got fixed by
https://github.com/sympy/sympy/commit/56fe9a9e3ae9c449fdbbd4332ba87bfbbd6b84a3

Ondrej

>
> which is obviously not the right expression
>
> If I do
>
> ccode(exp(Min(2,x)))
>
> I get: 'exp(Min(2,x))'
>
> which seems correct
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/36105b9f-eeef-4bc5-92eb-7aad845429c6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages