下面是我写的代码 def scalar_function(x, y): Returns the f(x,y) defined in the problem statement.deal with vector input x,y vfunc = np.vectorize(scalar_function(x,y))
return vfunc 这里我尝试做的是as::scalar_function只能处理标量输
我有一个函数foo(x,y),它接受两个标量(或标量列表),并返回一个标量输出(或从输入中双计算的标量列表)。我希望能够在两个正交阵列上评估这个函数,这样输出就是一个矩阵ij of foo(x[i], y[j])。我有一个for-循环版本,它解决了这个问题,如下所示:
x = np.range(50) # Could be linspaces, whatever the axis然而,这是可怕的