title: Fast dot product for a very special case
body: <p>Given a vector X of size L, where every scalar element of X is from a binary set {0,1}, it is to find a dot product z=dot(X,Y) if vector Y of size L consists of the integer-valued elements. I suggest, there must exist a very fast way to do it.</p>
  
  <p>Let's say we have <code>L=4; X[L]={1, 0, 0, 1}; Y[L]={-4, 2, 1, 0}</code> and we have to find <code>z=X[0]*Y[0] + X[1]*Y[1] + X[2]*Y[2] + X[3]*Y[3]</code> (which in this case will give us <code>-4</code>). </p>
  
  <p>It is obvious that X can be represented using binary digits, e.g. an integer type int32 for L=32. Then, all what we have to do is to find a dot product of this integer with an array of 32  integers. Do you have any idea or suggestions how to do it very fast?</p>