感谢所有有用的评论,我写了自己的加法器,似乎运行速度非常快.任何人都有任何建议让它变得更好,我很乐意接受它们.
我将对我正在研究的问题进行测试,一旦它表明成功,我将声称它具有功能性.
def integers(blk_size=100):
x = arange(0, blk_size)
while True:
yield x
yield -x -1
x += blk_size
#
# For convergent summation
# on not necessarily finite sequences
# processes in blocks which can be any size
# shape that the function can handle
#
def converge_sum(f, x_strm, eps=1e-5, axis=0):
total = sum(f(x_strm.next()), axis=axis)
for x_blk in x_strm:
diff = sum(f(x_blk), axis=axis)
if abs(linalg.norm(diff)) <= eps:
# Converged
return total + diff
else:
total += diff