If your result is only 0 and 1 you can use the fact that booleans are
integers in C. In this case, you would have Not(e1 <= e2) (i.e., e1 >
e2).

If you are dealing with more general numbers, see
https://github.com/sympy/sympy/pull/10209.

Aaron Meurer

On Sun, Dec 6, 2015 at 12:19 PM, zell <[email protected]> wrote:
> Suppose I have a sympy expression
>
> e1 op e2
>
> where op is any arithmetic comparison operator, such as <, >, <=,
>
> I want to generate a C code
>
> double f(x1,x2,...xn){
>   if (e1<=e2) return 0 else return 1;
> }
>
> where x1,...,x2 are free variables in either e1 or e2.
>
> How can I use sympy.printing.ccode, or sympy.utlilities.codegen to simplify
> this code generation? Thanks for your idea.
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> 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/2679496c-9d2b-40e9-8211-936b60310737%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/CAKgW%3D6%2B%3D0h73Q8V9U1QLY%3D%3Drkbr1EJiwE7teVSF76V6TQ4Tqsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to