我想为最小查找算法覆盖一些数组值。对于这些示例,我希望将第一行的值替换为math.inf.
它在 example 中工作正常c,但我不明白aand 中发生了什么b:
import numpy as np
import math
a = np.repeat(0, 9).reshape((3, 3))
a[0, :] = np.ones((3,)) * math.inf
print(a)
b = np.arange(9).reshape((3, 3))
b[0, :] = np.ones((3,)) * math.inf
print(b)
c = np.empty((3, 3))
c[0, :] = np.ones((3,)) * math.inf
print(c)
Run Code Online (Sandbox Code Playgroud)
输出:将无穷大显示为 example 中的行条目c,但-9223372036854775808在 examplea和 中b。
为什么覆盖现有输出时会产生影响?