@jit
def f_(path,stack,idx):
res = []
l = len(path)
for i in range(l):
for j in range(i+1,l):
### combine vector for union and intersection
path_combine = np.hstack((path[i],path[j]))
stack_combine = np.hstack((stack[i],stack[j]))
stack_sort = np.sort(stack_combine)
stack_diff = np.diff(stack_sort)
used_idx = np.where(stack_diff==0)[0]
### if not path.intersection and stack.intersection
if np.unique(path_combine).shape[0]==path_combine.shape[0] and \
len(used_idx) !=0:
for ele in stack_combine[used_idx]:
res.append(np.hstack((path_combine,np.array([ele],np.float64),idx)))
return res
path = np.array([[1,2,3],[2,3,9],[4,6,7],...,[6,7,14]]
### the vectors in stack have different dimension, as follows
### len(path)==len(stack)
stack = [[1,2],[3,4,5,6,7,8],[4],...,[3,4,6,8,91]]
idx = np.array([0],np.float64)
res = f_(path,stack,idx)
Список не был принят numba, но эти векторы не могут быть преобразованы в однородную матрицу. Как я могу использовать Numba для ускорения векторов с различными размерами? Большое спасибо!