Row-wise indexing in Numpy,i = np.indices(B.shape)[0]