示例#1
0
 /** The buffer content may be copied back on destruction to some
     final location */
 ~buffer() {
   /* If there is a final_data set and that points to something
      alive, copy back the data through the shared pointer */
   if (auto p = final_data.lock())
     std::copy_n(access.data(), access.num_elements(), p.get());
   /* If data are shared with the host but not concretely, we would
      have to copy back the data to the host */
   // else if (shared_data)
   //   std::copy_n(access.data(), access.num_elements(), shared_data.get());
 }
示例#2
0
/** @brief centroid functor constructor. prepare the gradients  */
centroid::centroid(const boost::multi_array_ref<float,3> & im) : image(im)
{
    boost::array<size_t, 3> kernel_dims;
    for(size_t d=0;d<3;++d)
        kernel_dims[d] = (im.shape()[d]<3)?1:3;
    /*cout<<"using neighbourhood (";
    copy(kernel_dims.begin(), kernel_dims.end(), ostream_iterator<size_t>(cout, ", "));
    cout<<") ...";*/
    ngb.resize(kernel_dims);

    /*slides.resize(
        3u*accumulate(kernel_dims.begin(), kernel_dims.end(), 1u, multiplies<size_t>()),
        0.0);


    slides =
    {
         {-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1},
         {-1,-1,-1,0,0,0,1,1,1,-1,-1,-1,0,0,0,1,1,1,-1,-1,-1,0,0,0,1,1,1},
         {-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1}
    };*/
}
示例#3
0
void fill(boost::multi_array_ref<V1,NumDims> &x, const V2 &v) {
    std::fill_n(x.data(), x.num_elements(), v);
}
示例#4
0
 template <typename T, size_t dim> static void fill (boost::multi_array_ref<T, dim>& array, const T& value) {
   std::fill (array.data (), array.data () + array.num_elements (), value);
 }