element-wise multiplication of two vectors in c++
<p>I am trying to do the following mathematical operation with two vectors:</p>

<pre><code>v1 = [a1][a2][a3][a4][a5]
v2 = [b1][b2][b3][b4]b5]
</code></pre>

<p>Want to compute:</p>

<pre><code>v = [a2*b2][a3*b3][a4*b4][a5*b5]
</code></pre>

<p>Note that I did not want the first element in the new vector.</p>

<p>I was wondering if there is a more efficient (one-liner) way to multiply (element-wise) two vectors in c++ than a for-loop (using push back).  My current approach is as follows,</p>

<pre><code>for(long i=1;i &lt; v1.size();++i){
v.push_back(v1[i]*v2[i]);
}
</code></pre>

<p>I also tried the following,</p>

<pre><code> for (long i = 1; i &lt; v1.size(); ++i){
     v[i-1] = v1[i]*v2[i];
 }
</code></pre>

<p>Any suggestions?</p>
