3

What is the cause of this error?

Compile[{{r, _Integer, 2}, {d, _Integer, 2}},
  pos = Position[MapThread[#1 > #2 &, {r, d}, 2], x_ /; x == True]]

Compile::cplist: MapThread[#1 > #2&, {r, d}, 2] should be a tensor of type Integer, Real, or Complex; evaluation will use the uncompiled function. >>

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
jack cilba
  • 357
  • 1
  • 9

1 Answers1

0
Compile[{{r, _Integer, 2}, {d, _Integer, 2}},
 a = Position[Sign@MapThread[#1 - #2 &, {r, d}], 1]
 ]
jack cilba
  • 357
  • 1
  • 9
  • when there is some error from using map in compile, with adding IntegerPart@ to the list that will be map, the error will not occur again. but why? – jack cilba Jan 11 '16 at 21:41
  • Regarding your comment, probably the compiler cannot tell what type the list will be and is expecting an Integer array. You can often fix this by using a third argument in Compile; see the documentation for details. Post a new question with a minimal self-contained example if you need help. – Mr.Wizard Feb 03 '16 at 12:40