Tag Info

New answers tagged


This seems rather be a error of determining the type of i, j and k than Sum itself. When you introduce your iterator variables in a Module and make clear that they are of type integer, it compiles fine for me: fc = Compile[{{x, _Real, 2}}, Module[{i = 0, j = 0, k = 0}, Sum[x[[i, k]]*x[[j, k]], {k, 5}, {i, 12}, {j, i + 1, 12}]] ] Btw, I want to note ...


Quoting a comment by halirutan, Please note that matrix operations are in general very very fast in Mathematica without using Compile. In fact, it is easily possible that you slow something down. Try to use built-in functions first. Your observation about the types is correct. Compile[] can only handle tensors of one type.. either Real, Integer, ...


How about mv = Compile[{{v, _Real, 1}, {id, _Real, 2}}, id.v, CompilationTarget -> "C" ]; v = RandomReal[{0, 1}, 500]; id = N[IdentityMatrix[500]]; res=mv[v, id] It works without trouble.


The reason for this behavior is that autocompilation always uses settings equivalent to "RuntimeOptions" -> {"Quality", "WarningMessages" -> False}. As previously noted in Silvia's answer, the automatic compilation is invoked for input exceeding SystemOptions["CompileOptions" -> "FoldCompileLength"] (* {"CompileOptions" -> ...

Top 50 recent answers are included