title: Creating a sparse matrix from numpy array
body: <p>I need to create a matrix with values from a numpy array. The values should be distributed over the matrix lines according to an array of indices.</p>
  
  <p>Like this:</p>
  
  <pre><code>&gt;&gt;&gt; values
  array([ 0.73620381,  0.61843002,  0.33604769,  0.72344274,  0.48943796])
  &gt;&gt;&gt; inds
  array([0, 1, 2, 3, 2])
  &gt;&gt;&gt; m = np.zeros((4, 5))
  &gt;&gt;&gt; for i, (index, value) in enumerate(zip(inds, values)):
          m[index, i] = value
  &gt;&gt;&gt; m
  array([[ 0.73620381,  0.        ,  0.        ,  0.        ,  0.        ],
         [ 0.        ,  0.61843002,  0.        ,  0.        ,  0.        ],
         [ 0.        ,  0.        ,  0.33604769,  0.        ,  0.48943796],
         [ 0.        ,  0.        ,  0.        ,  0.72344274,  0.        ]])
  </code></pre>
  
  <p>I'd like to know if there is a vectorized way to do it, i.e., without a loop. Any suggestions?</p>