Translate Matlab's vector assignment into Python form -


i'm trying translate matlab code python (using numpy). i'm not familiar matlab, , i've encountered line i'm having trouble parsing:

w(idx(1:p, 1), 1) = v(idx(1:p, 1), 1) - theta; 

i'd hazard guess p-long head of x being used indices select p entries of w, , entries in w being replaced corresponding entries in v (less scalar theta).

messing around in octave, seems accurate description of it's doing, can't find documentation effect.

in case, what's best way re-write code in python? i've looked @ numpy 'tentative tutorial' try , find elegant way it, , looks this might i'm looking for. however, i'm having trouble making nice, particularly assignment operator. there more elegant or python-idiomatic ways assignment operation?

this @dan wrote in comments, accounts zero-based indexing in python:

w[idx[:p, 0], 0] = v[idx[:p, 0], 0] - theta 

not sure if wanted more elegant that. zeros required if first column should modified.


Comments