the matrix Z is defined like this:
N = 15
Z = np.zeros((N, N))
and I want different threads to fill it so I'm need to create a shared memory matrix or array. I'm doing this:
Z_shared = Array('d', Z)
But I get this error:
TypeError: only length-1 arrays can be converted to Python scalars
Which I suppose means that Array doesn't accept matrices. Is there another function that does what I need or should I convert Z to a vector first and then pass it to Array. If so is there a function that does this for me. I don't want to loop over Z since N can be very large.
I'm fill Z_shared in another function that is called like this:
from multiprocessing import Pool, Array
pool = Pool(processes=1)
def foo(data):
x, y, val = data
Z_shared[x][y] = val
pool.map(fooe, DATA)
'data' is a tuple of indexes and values and 'DATA' is a list a of tuples.
thank you