Skip to main content

Timeline for Indexed variables in compile

Current License: CC BY-SA 4.0

7 events
when toggle format what by license comment
Oct 15, 2018 at 19:13 comment added NeverMind @LeonidShifrin: Yes, this is exactly the problem I was referring to. Would have been great to use these kind of indexed variables without explicitely specifying them which doesn't seem to be possible then. But I like Henrik Schumacher's workaround. Thank you for the links xzczd!
Oct 15, 2018 at 15:07 answer added Henrik Schumacher timeline score: 4
Oct 15, 2018 at 14:59 comment added xzczd If I understand your question correctly, I think we can achieve something similar with the help of code-generation technique e.g. here. But it's hard to help without a complete example, so once again, please be more specific. BTW, another related post is this.
Oct 15, 2018 at 14:57 comment added Leonid Shifrin I don't remember exactly, but I think what I meant was that while you can compile this: 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 loading Get["CompiledFunctionTools`"] and calling CompilePrint on resulting CompiledFunctions.
Oct 15, 2018 at 14:44 comment added NeverMind It's just the idea to generate something like Table[var[i],{i,1,10}] within Compile and then assign values to the different var[i]. That's what I mean about indexed variables. Sorry for the confusion.
Oct 15, 2018 at 14:41 comment added xzczd I'm afraid this is a bit too board, can you add a specific example?
Oct 15, 2018 at 14:28 history asked NeverMind CC BY-SA 4.0