I have the following array:
arr = np.array([[1, 1, 1, 1, 1, 1],
[2, 0, 0, 0, 0, 2],
[3, 0, 0, 0, 0, 3],
[4, 4, 4, 4, 4, 4]])
inverse_slice = arr[1:3, 1:5]
I want to update the values of all values in the array, execpt for the values in the slice. For example, this could be multiplying all values with 2, exepct for values in the slice (the rectangle of 0's in this case).
How can I achieve this in an efficient manner?
NOTE: Performance is critical, as the actual array I'm processing is very large, so iteration using Python for-loops is not sufficient.