Efficient a += b*c in numpy

Viewed 57

Is there a way to calculate c+= a*b in numpy without extra temporary memory allocation/copy? The way I understand it, to compute the expression above, numpy will use temporary memory for a*b and then compute c+=tmp.
I know we can use np.multiply(a, b, out=c) to calculate c=a*b without using extra temporary memory, but can we do something similar to do c+=a*b, not just c=a*b.

Of course, I'm using operators + and * as an example. The questions applies to any combination of +=, -=, /=, +=, +, -, *, /, %, ....

0 Answers
Related