In this contribution Leonid Shifrin says that
You can not really use indexed variables in Compile, although it may appear that you can.
This sounds ambiguous to me. Is it possible or is it not possible? And if the former is true, how to implement indexed variables in compile? This would simplify one of my programs a lot.
Table[var[i],{i,1,10}]
withinCompile
and then assign values to the differentvar[i]
. That's what I mean about indexed variables. Sorry for the confusion. $\endgroup$Compile[{{x[1], _Integer}, {y[1], _Integer}}, x[1] + y[1]]
down to MVM byte code or C just fine, the following, for example:Compile[{{a, _Integer}, {b, _Integer}}, Module[{x}, x[1] = a; x[2] = b; x[1] + x[2]]]
, will use the calls to main evaluator. You can see that by loadingGet["CompiledFunctionTools`"]
and callingCompilePrint
on resultingCompiledFunction
s. $\endgroup$