I want to use multiprocessing to improve the time execution of the following function:
def verif(mat1,tab):
import numpy as np
mat=np.matrix(mat1)
t=1
leng=len(mat)
mm=mat+np.eye(leng)
for u in range(leng-1):
for v in range(u+1,leng):
if ( np.all(mm[tab,u]==0) | np.all(mm[tab,v]==0)):
t=0
break
else:
if np.array_equal(mm[tab,u],mm[tab,v]):
t=0
break
if t==0:
break
return t
It’s a brute force program which test all column combination of the matrix ‘mm’.
multiprocessing rewriting of the above code.
I am trying to add this function :
def check_pair(mm, tab, u, leng):
for v in range(u + 1, leng):
if np.all(mm[tab, u] == 0) or np.all(mm[tab, v] == 0):
return False
if np.array_equal(mm[tab, u], mm[tab, v]):
return False
return True,
But, I don’t know how I can use it in multiprocessing
New contributor
HTeX is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
8