title: How can I convert a forloop to Numpy single operation?
body: <p>I want to improve calculation speed. I have this code: </p>
  
  <pre><code>for index_subsequence in range(number_of_sequences):
       sequence = sequences[index_sequence]
       multiplication = np.multiply(sequence, matrix)
  </code></pre>
  
  <p>Let's use concrete dimensions:</p>
  
  <p>"matrix" has a shape of (2207, 12).</p>
  
  <p>"sequences" has a shape of (1884, 12).
  Consequently, "sequence" is a vector is a vector with 12 entries.</p>
  
  <p>np.multiply(sequence, matrix) yields another (2207, 12) matrix, where each row is multiplied with "sequence".</p>
  
  <p>The code works correctly, but I want to get rid of the for loop.</p>
  
  <p>What I need is a new 3D array "multiplications" which has the shape (number_of_sequences, 2207, 12).</p>
  
  <pre><code>multiplications[0] = np.multiply(sequences[0], matrix)
  multiplications[1] = np.multiply(sequences[1], matrix)
  </code></pre>