假设我有两个长度相同的1d数组(比如说n),现在我想实现一个“cumdot”函数,它输出长度为n的1d数组,可以用纯python代码实现
def cumdot(a,b):#a,b are two 1d arrays with same length
n = len(a)
output = np.empty(n)
for i in range(n):
output[i] = np.dot(a[:i+1],b[:i+1])
return output
如何更有效地实现“cumdot”功能?你知道吗
Tags:
我认为纯python的意思是:使用python的核心!
相关问题 更多 >
编程相关推荐