title: How to implement properly an inline function in the device that returns a vector to another device function?
body: <p>I want to implement properly an inlined device function that fill out  a vector of dynamic size and return the filled vector like:</p>
  
  <pre><code>__device__  inline   thrust::device_vector&lt;double&gt; make_array(double zeta, int l)
  {
    thrust::device_vector&lt;double&gt; ret;
    int N =(int)(5*l+zeta); //the size of the array  will depend on l and zeta, in a complex way...
    // Make sure of sufficient memory allocation
    ret.reserve(N);
    // Resize array
    ret.resize(N);
    //fill it:
    //for(int i=0;i&lt;N;i++)
    // ...;
    return ret;
  }
  </code></pre>
  
  <p>My goal is to use the content of the returned vector in another device function like:</p>
  
  <pre><code>__device__  inline double use_array(double zeta,int l)
  {
    thrust::device_vector&lt;double&gt; array = make_array(zeta, l);
  
    double result = 0;
  
    for(int i=0; i&lt;array.size(); i++)
      result += array[i];
  
    return result;
  }
  </code></pre>
  
  <p>How can I do it properly? my feeling is that a thrust vector is designed for this type of task, but I want to do it properly. What is the standard CUDA approach to this task?</p>