Comment #3 on issue 2557 by brad.froehle: inline Piecewise C code
constructs not actually valid C
http://code.google.com/p/sympy/issues/detail?id=2557
It generalizes by nesting the ternary statements, the same way they would
be evaluated:
if (C1) {
E1
}
else {
if (C2) {
E2
}
else {
E3
}
}
would turn into
(C1) ? (E1) : (C2 ? E2 : E3)
For example, the provided code in comment #1 returns
var('X')
print ccode(2*Piecewise((-1,X<0), (1,X>0), (0,True)))
2*((X < 0) ? (-1) : (((0 < X) ? (1) : (0))))
There may be some unnecessary parenthesis, but it is probably better to err
on the side of caution.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" 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-issues?hl=en.