title: numpy sum of squares for matrix
body: <p>I do have a matrix with observations in rows (measurements at differnt pH) with data points as columns (concentration over time). So one row consists of differnt data points for one pH.</p>
  
  <p>I do want to fit an ODE to the data. So i defined a cost function and would like to calculate the sum of squares for all observatoins. Taking the sum of sqares for this matrix should work like:</p>
  
  <pre><code>res = y - yhat                        # calculate residuals
  ssq = np.diag(np.dot(res.T,res))      # sum over the diagonal
  </code></pre>
  
  <p>is that correct ?</p>