title: Multiply device vector by constant
body: <p>I am using thrust for a project, and it seem to be missing some basic functionality :-</p>
  
  <p>In c++, the easiest way to multiply a vector by a constant is using <code>std::transform</code> and <code>std::bind1st</code> like so:</p>
  
  <pre><code>std::transform(vec.begin(), vec.end(), vec.begin(),
             std::bind1st(std::multiplies&lt;double&gt;(),myConst)); 
  </code></pre>
  
  <p>But apparently <code>bind1st</code> and <code>bind2nd</code> does not work with thrust.</p>
  
  <p>So, is there an easy way to multiply a vector by a constant in thrust?</p>
  
  <p><strong>PS</strong>: Currently I am using my own functor to do the multiplication like so:</p>
  
  <pre><code>thrust::for_each(vec.begin(), vec.end(), multiplyByConstant&lt;double&gt;(myConst))
  </code></pre>
  
  <p>where</p>
  
  <pre><code>    template&lt; typename T &gt;
      struct multiplyByConstant
      {
      const T constant;
  
      multiplyByConstant(T _constant) : constant(_constant) {}
  
       __host__ __device__
       void operator()( T&amp; VecElem) const 
        {
          VecElem=VecElem*constant;
        }
      };
  </code></pre>
  
  <p>But writing a functor to do a simple multiplication seems like overkill. There surely must be an easier way.</p>