I have a (k,n) numpy array (call it D) from which I have to zero out specific entries in that array based on the indices given in another numpy array, say y, that's (n,1).
Here are the 2 indices where D[i,j] has to be set to zero:
The index of
yis the 2nd element, or jThe value of
yis the 1st element, or i
I tried doing this:
tmp = np.where(y==0, 0, D)
result = np.add(tmp, D[1:,:])
But I'm getting ValueError: operands could not be broadcast together with shapes (3,100) (2,100) .
Is there a cleaner way I could zero out those specific elements from D using numpy functions?