I have a function that takes lots of optional arguments (basically some design parameters, about 10 of them) and performs some basic algebraic calculations involving complex numbers with the options. The function generally evaluates to a complex number. For example, I have something like:
Options[myfunc] = {param1 -> 1.0, param2 -> 2.0, param3 -> 3.0, etc.};
myfunc[x, opts: OptionsPattern[]] :=
Module[
{var1,var2, etc.},
var1 = OptionValue[param1]; etc.
I*x*var1 + var2 + 1/(var3 + I var4)*... etc.
]
The function is listable in x
and I want to evaluate it as fast as possible for different x's.
I need to use this function in lots of plotting, solving and optimization procedures as part of a Manipulate
GUI. The problem is that such procedures takes significant amount of time (~ 10s) which renders the Manipulate
GUI unusable.
My question is if I can compile myfunc
somehow to speed up the rest of the processing? If not, is there an alternative way to define a function with Options (or optional arguments) to make it compilable? Can I compile the entire Manipulate
GUI? If compilation is not possible, any hints about how to define such function in an efficient way?
myFunc[commsAssoc_]
within the assoc you have different keys referring to both the data and the parameters, and you control the function processing by writing to the association before calling it, and potentially write the output back before quitting the function. Its not a particularly clean way of doing it but seems to work reasonably well on our large-ish datasets. $\endgroup$