我正在尝试B使用包含我想要的索引的向量来索引njit 函数中的二维矩阵, 这里a的矩阵切片是D一个最小的示例:
import numba as nb
import numpy as np
@nb.njit()
def test(N,P,B,D):
for i in range(N):
a = D[i,:]
b = B[i,a]
P[:,i] =b
P = np.zeros((5,5))
B = np.random.random((5,5))*100
D = (np.random.random((5,5))*5).astype(np.int32)
print(D)
N = 5
print(P)
test(N,P,B,D)
print(P)
我在线路上收到 numba 错误 b = B[i,a]
File "dj.py", line 10:
def test(N,P,B,D):
<source elided>
a = D[i,:]
b = B[i,a]
^
This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.
我不明白我在这里做错了什么。代码在没有@nb.njit()装饰器的情况下工作
鸿蒙传说
跃然一笑
相关分类