from numpy.linalg import inv
from numpy import array
def test (A,U,m):
Lambda=array(list(map(lambda x:inv(U)@A[x]@U,(range(m*m)))))
This is a simple code that calculates an array product. How can I right this in cython with parallel programming in the loops with prange? I tried many times but in order to do so, I need to use nogil for prange. But inv() needs the gil. How can this be done efficiently in order to be faster than my original code?