Python how to set values in a matrix given an array element of which representing the column of the matrix
<p>Suppose I have a N x N matrix M and a N elements array A. A[i] represents M[i, A[i]] entry in M. How do I quickly set corresponding entry in M to value 1 given the array A?</p>

<p>By using numpy so far, what I tried is:
M[0:A.shape[0], A]=1
But this does not work and I don't want to run into a loop which is kind of costy when N is big.</p>