How to modify different parts of a numpy array of complex numbers in parallel using python? -
how modify different parts of numpy array of complex numbers in parallel using python? question seems give answer numpy array real coefficients: is shared readonly data copied different processes python multiprocessing? , not complex coefficients.
you need view array containing twice number of floats floats complex numbers:
>>> shared_array_base = multiprocessing.array(ctypes.c_double, 3*3*2) >>> shared_array = np.ctypeslib.as_array(shared_array_base.get_obj()) >>> shared_array = shared_array.view(np.complex128).reshape(3, 3)
the complex number format [re0, im0, re1, im1, re2, im2, ...]:
>>> shared_array[1,1] = 1+2j >>> shared_array.base array([ 0., 0., 0., 0., 0., 0., 0., 0., 1., 2., 0., 0., 0., 0., 0., 0., 0., 0.]) >>> shared_array.base.base <multiprocessing.sharedctypes.c_double_array_18 object @ 0x7f7c1b5d1f80>
Comments
Post a Comment