title: Is there a way to have even faster dot products using Eigen?
body: <p>So, I am using Eigen to perform matrix math on my own data structures, which encapsulate std::arrays. I essentially obtain the dot product as such:</p>
  <pre><code>Eigen::Map&lt;const Eigen::Matrix&lt;D, N, 1&gt;&gt; m1(my_array1.data());
  Eigen::Map&lt;const Eigen::Matrix&lt;D, N, 1&gt;&gt; m2(my_array2.data());
  return m1.dot(m2);
  </code></pre>
  <p>This is pulled from a templated class, hence the stand-ins for the matrix dimensions, but otherwise it's fairly straightforward. I noticed that I'm getting some overhead to create the maps, and then there is of course the cost of the actual dot product.</p>
  <p>Overall, I'm very happy with Eigen's performance, it's definitely much faster than my previous naive implementation of a dot product. However, since my program uses dot products so heavily, I was wondering if any wizards out there had some tips to speed this up further. Dot products account for about 10% of my program's total runtime, so it would be a lot of bang for my buck optimization-wise. My only constraint is that my vectors still live in contiguous stack variables (I'm not married to std::array specifically, but I like how they're currently getting the job done).</p>
  <p>So, any tips? Or is this about the best I can get?</p>