(*can compiled*)
Compile[{}, Table[Boole[a == b == c], {a, 3}, {b, 3}, {c, 3}],
CompilationTarget -> "C"][]
(*can compiled*)
Compile[{}, Table[Boole[a != b != c], {a, 3}, {b, 3}, {c, 3}]][]
(*can't compiled*)
Compile[{}, Table[Boole[a != b != c], {a, 3}, {b, 3}, {c, 3}],
CompilationTarget -> "C"][]

Why doesn't the third snippet code compile when I set CompilationTarget -> "C"?
Answer
I confirm it with Mathematica 9.0.1 and Linux. It seems that double inequalities is not yet implemented for CompilationTarget -> "C".
You can manually expand a != b != c to b != a && c != a && c != b.
LogicalExpand can also be helpful
With[{neq = LogicalExpand[a != b != c]},
Compile[{}, Table[Boole[neq], {a, 3}, {b, 3}, {c, 3}],
CompilationTarget -> "C"]]
no errors
Comments
Post a Comment