title: Calculating column-wise dot product between two matrices
body: <p>I would like to determine the dot product between the <em>i</em>th column in one matrix  and the <em>i</em>th column in a second matrix. The end result will be an array containing <em>i</em> dot products. </p>
  
  <p>Here is a reproducible example of what I want to do:</p>
  
  <pre><code>#Generate two matrices with 10 columns each with 5 rows (thus i in this case is 10)
  m1 &lt;- replicate(10, rnorm(5)) 
  m2 &lt;- replicate(10, rnorm(5)) 
  
  #Inefficiently calculate dot product of ith column in m1 with ith column in m2
  d1 &lt;- t(m1[,1]) %*% m2[,1]
  d2 &lt;- t(m1[,2]) %*% m2[,2]
  ...
  d10 &lt;- t(m1[,10]) %*% m2[,10]
  
  #End with all dot products in array
  d.final &lt;- c(d1, d2, d10)
  </code></pre>
  
  <p>Any help here will be appreciated!</p>
  
  <p>Ken</p>