Ufunc非常灵活–在我们看到标量和数组之间的操作之前.我们也可以在两个数组之间进行操作:
In [18]: np.arange(5) / np.arange(1,6)
# 每个对应的元素想除,要保证两个数组...如下在add ufunc上调用reduce会返回数组中所有元素的总和
# 相加聚合
In [98]: x = np.arange(5)
...: np.add.reduce(x)
Out[98]...In [101]: np.add.accumulate(x)
Out[101]: array([ 1, 3, 6, 10], dtype=int32)
In [102]: np.multiply.accumulate...:最小值,最大值和介于两者之间的所有值。...6, 9, 12, 15],
[ 4, 8, 12, 16, 20],
[ 5, 10, 15, 20, 25]])
ufuncs的另一个极其有用的功能是能够在不同大小和形状的数组之间进行操作的能力