Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
(*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"?

share|improve this question
up vote 4 down vote accepted

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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