title: Block scalar-vector multiplication in numpy
body: <p>I have a large 1-dimensional array <code>x</code> which I've got by concatenation of smaller arrays <code>x_0 ,..., x_m-1</code> of different length. I also know the list <code>L</code> of the length of each <code>x_i</code>. Given an array <code>a</code> of length <code>m</code>, the goal is to compute a flat array <code>[a[0]*x0, a[1]*x1,...]</code>.</p>
  
  <p>For example, if I have <code>x = np.array([1,2,3,4,5])</code> and <code>a=np.array([2,-1]), L = [2,3]</code>, then the result should be
  <code>np.array([2,4,-3,-4,-5])</code></p>
  
  <p>Is there any simpler (faster, more pythonic, etc.) way to do this in numpy, than this naive implementation?</p>
  
  <pre><code>L.insert(0,0)
  cs = np.cumsum(L)
  y = np.empty(x.shape) 
  for i in range(m):
      y[cs[i]:cs[i+1]] = a[i] * x[cs[i]:cs[i+1]]
  </code></pre>
  
  <p>I can also do this in Numba.</p>
  
  <p><code>m</code> is of order of hundreds, the length of each <code>x_i</code> is around 1e6.</p>