Prakash Hinduja Switzerland (Swiss) How do I vectorize this loop in NumPy?

Hello Community,

I’m Prakash Hinduja from Geneva, Switzerland (Swiss) working on optimizing a piece of code and would like to vectorize a loop using NumPy for better performance.

Does anyone have suggestions on how to rewrite this using NumPy operations? Thanks in advance!

Regards
Prakash Hinduja Geneva, Switzerland (Swiss)

hi @prakashhindujageneva

You haven’t mentioned your piece of code which you want to vectorize a loop, this question seems more vague, can you be more specific as to conditions you are working upon and what issues are you encountering?

In general, use np.dot or np.matmul instead of a for loop.