@zaq's quad . .
fooobar.com/questions/1664173/... , vectorize , , . quad . , ws. x, , quad. quad integrand Python, numpy.
cython , C. , , quad. Cython .
, integrand ( ) cython, numpy .
def f(x, w):
if w < 0: return np.abs(x * w)
else: return np.exp(x) * w
if w<0 w . , w? ,
np.array([f(x, w) for w in ws]).sum()
fn(x, ws).sum()
, x w , , math.exp .. np.exp. log abs.
f(x,w), x w, 2d. , temp integrand . quad x, , .
f(x,w) nx10 x=np.linspace(-1,1,n) ws, () .