title: Numpy array and for loop: how to improve it
body: <p>I am new with Python and I have a question about a for loop to speed up.</p>
  
  <p>Let "u" be an numpy array of dimension (N,K) and let "kernel_vect" be a numpy array of dimension (K,) both of float64 numbers.
  I would like to speed up the following code (by eliminating the for loop for example)</p>
  
  <pre><code>Kernel_appo = np.zeros((N**2,))
      for k in range(K):
          uk = u[:,k]
          Mat_appo = np.outer(uk,uk)
          Kernel_appo = Kernel_appo  + kernel_vect[k] * routines.vec(Mat_appo)
  </code></pre>
  
  <p>Any idea? Thanks!</p>