Need help vectorizing code

Joshua Landau joshua at landau.ws
Sat Jan 18 16:04:32 EST 2014


On 18 January 2014 20:51, Kevin K <richyokevin at gmail.com> wrote:
> def foo(X, y, mylambda, N, D, epsilon):
> ...
>         for j in xrange(D):
>             aj = 0
>             cj = 0
>             for i in xrange(N):
>                 aj += 2 * (X[i,j] ** 2)
>                 cj += 2 * (X[i,j] * (y[i] - w.transpose()*X[i].transpose() + w[j]*X[i,j]))

Currently this just computes and throws away values...



More information about the Python-list mailing list