5
$\begingroup$
(*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"][]

enter image description here

Why doesn't the third snippet code compile when I set CompilationTarget -> "C"?

$\endgroup$
4
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Confirmed with 9.01 and Win8x64 $\endgroup$ – Hector Oct 15 '13 at 15:59
  • 1
    $\begingroup$ Label is not implemented either: Compile[{}, Label[1]; Goto[1], CompilationTarget -> "C"]. Both of these should be considered bugs in the CCompilerDriver` package, IMO. $\endgroup$ – Oleksandr R. Oct 15 '13 at 17:43
  • $\begingroup$ Not implemented in version 10.1 either $\endgroup$ – dr.blochwave May 19 '15 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.