This is a very general question -- is there any way to vectorize consequential simulation (where next step depends on previous), or any such iterative algorithm in general?
Obviously, if one need to run M simulations (each N steps) you can use for i in range(N)
and calculate M values on each step to get a significant speed-up. But say you only need one or two simulations with a lot of steps, or your simulations don't have a fixed amount of steps (like radiation detection), or you are solving a differential system (again, for a lot of steps). Is there any way to shove upper for-loop under the numpy
hood (with a speed gain, I am not talking passing python function object to numpy.vectorize
), or cython-ish approaches are the only option? Or maybe this is possible in R or some similar language, but not (currently?) in Python?