title: How to multiply a vector and scalar in C++?
body: <p>I would like to multiply a vector with a scalar. This vector was created using the accepted answer to <a href="https://stackoverflow.com/questions/41030499/how-to-create-a-row-vector-with-elements-from-0-up-to-and-including-n-in-c">this question</a> of mine namely:</p>
  
  <pre><code>std::vector&lt;int&gt; n(N + 1);
    std::iota(begin(n), end(n), 0);
  </code></pre>
  
  <p>and I would like to multiply this vector, <code>n</code>, with a scalar (specifically of type double, if it is relevant here) called <code>npi</code>. </p>
  
  <p>I have seen <a href="https://stackoverflow.com/q/3885095/1876983">this answer</a> to a previous question here, but it wasn't all that helpful. The way I attempted to implement it was by adding:</p>
  
  <pre><code>std::transform(n.begin(), n.end(), n.begin(),
             std::bind1st(std::multiplies&lt;T&gt;(),pin));
  </code></pre>
  
  <p>to my C++ program. This returned the compile error:</p>
  
  <pre><code>error: ‘T’ was not declared in this scope
                  std::bind1st(std::multiplies&lt;T&gt;(),pin));
  </code></pre>
  
  <p>I would like to call the vector created by multiplying this vector with a scalar <code>npi</code>, so please do not give me code that will call this new vector <code>n</code> (i.e., overwriting my existing <code>n</code> vector). </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>If it will placate whomever voted to close this question, here is my full program:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;cmath&gt;
  #include &lt;utility&gt;
  #include &lt;unistd.h&gt;
  #include &lt;algorithm&gt;
  #include &lt;numeric&gt;
  /*#include &lt;armadillo&gt;*/
  
  using namespace std;
  /*using namespace arma;*/
  
  double N  = 1000.0;
  double x0 = 0;
  double x1 = 100;
  double pin = M_PI / double(N);
  
  int main() {
    std::vector&lt;int&gt; n(N + 1);
    std::iota(begin(n), end(n), 0);
    std::transform(n.begin(), n.end(), n.begin(),
                 std::bind1st(std::multiplies&lt;T&gt;(),pin));
    for(double i: n)
    {
      std::cout &lt;&lt; i &lt;&lt; '\n' &lt;&lt; std::scientific;
    }
  }
  </code></pre>