在一个使用numba编译的nopython函数中,我需要使用另一个数组中的值作为索引来索引一个数组。这两个数组都是numpy浮点数数组。
例如:
例如:
@numba.jit("void(f8[:], f8[:], f8[:])", nopython=True)
def need_a_cast(sources, indices, destinations):
for i in range(indices.size):
destinations[i] = sources[indices[i]]
我的代码有所不同,但让我们假设这个愚蠢的例子可以重现问题(即,我不能使用 int 类型的索引)。据我所知,在 nopython jit 函数内部,我不能使用 int(indices[i]) 或 indices[i].astype("int")。
我该怎么做呢?