I am trying to do some matrix calculations with numpy and some sparse matrices. For that I want to ignore the zeros in my matrix and just access some values, but I also need to overwrite them.
import numpy as np
a=np.random.rand(5,5)
#does not change a:
a[[1,2],...][...,[1,2]]=np.array([[0,0],[0,0]])
#just changes (1,1) and (2,2)
a[[1,2],[1,2]]=np.array([0,0])
I would like to overwrite [1,1],[1,2],[2,1],[2,2] with zeros.