Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • $\begingroup$ Thanks! That seems to do the trick. It looks like this is building the table on the fly each time. Do you know if there is much computational cost in that? I'm wondering if it is any faster to pre-construct proj for the given modes, ala proj[\[Theta]_, \[Phi]_]:= proj[modes][\[Theta],\[Phi]]. I ask because proj is going inside FindMaximum. In that the number of modes always stays the same, just the angles change. $\endgroup$ Commented Mar 6, 2013 at 17:32
  • $\begingroup$ Since the variables $\theta$ and $\phi$ are inside the sglmn, you would indeed have to re-do the sum for every new $\theta$ and $\phi$. That's why I don't see any significant room for improvement in terms of efficiency. But certainly you can leave out the modes argument if that stays fixed as a global variable. Then you don't even need to include it in my definition above, just make sure modes is defined once you call the function. $\endgroup$ Commented Mar 6, 2013 at 17:42
  • $\begingroup$ As far as I see it, that would still mean the whole MapThread procedure is done every time the function is called. I think the OP wants to precompute everything, to get a function that really only inserts the arguments into the precomputed list. $\endgroup$ Commented Mar 6, 2013 at 17:46
  • $\begingroup$ @einbandi But that essentially costs nothing. $\endgroup$ Commented Mar 6, 2013 at 18:01
  • $\begingroup$ Good point. I think it's interesting nevertheless, how one can compute complicated things and turn them to a function afterwards. Is there a standard way of replacing certain variables in an expression by Slots in order to create a function? $\endgroup$ Commented Mar 6, 2013 at 18:05