Parallel map and parallel for-loop¶
Often one is interested in the output of a given function as a single-parameter is varied. For instance, we can calculate the steady-state response of our system as the driving frequency is varied. In cases such as this, where each iteration is independent of the others, we can speedup the calculation by performing the iterations in parallel. In QuTiP, parallel computations may be performed using the
qutip.parallel.parallel_map function or the
qutip.parallel.parfor (parallel-for-loop) function.
To use the these functions we need to define a function of one or more variables, and the range over which one of these variables are to be evaluated. For example:
In : def func1(x): return x, x**2, x**3 In : a, b, c = parfor(func1, range(10)) In : print(a) [0 1 2 3 4 5 6 7 8 9] In : print(b)