コード例 #1
0
ファイル: multi_array.hpp プロジェクト: K-ballo/hpx
    void load(input_archive& ar, boost::multi_array<T, N, Allocator>& marray, unsigned)
    {
        boost::array<std::size_t, N> shape;
        ar & shape;

        marray.resize(shape);
        ar & make_array(marray.data(), marray.num_elements());
    }
コード例 #2
0
    void precompute(double distance, double scalex, double scaley)
    {
        double const radius2 = distance * distance;

        width  = 2* ceil(distance / scalex) + 1;
        height = 2* ceil(distance / scaley) + 1;
        in_distance.resize(boost::extents[height][width]);
        std::fill(in_distance.data(), in_distance.data() + in_distance.num_elements(), false);
        parents.resize(boost::extents[height][width]);
        std::fill(parents.data(), parents.data() + parents.num_elements(), std::make_pair(-1, -1));

        centerx = width  / 2;
        centery = height / 2;
        parents[centery][centerx] = std::make_pair(-1, -1);

        for (unsigned int y = 0; y < height; ++y)
        {
            for (unsigned int x = 0; x < width; ++x)
            {
                int dx = (centerx - x);
                int dy = (centery - y);
                if (dx == 0 && dy == 0) continue;

                double d2 = dx * dx * scalex * scalex + dy * dy * scaley * scaley;
                in_distance[y][x] = (d2 < radius2);
                if (abs(dx) > abs(dy))
                {
                    int parentx = x + dx / abs(dx);
                    int parenty = y + rint(static_cast<double>(dy) / abs(dx));
                    parents[y][x] = std::make_pair(parentx, parenty);
                }
                else
                {
                    int parentx = x + rint(static_cast<double>(dx) / abs(dy));
                    int parenty = y + dy / abs(dy);
                    parents[y][x] = std::make_pair(parentx, parenty);
                }
            }
        }
    }
コード例 #3
0
ファイル: serialization.hpp プロジェクト: feelpp/feelpp
void save( Archive & ar,
           const boost::multi_array<double,2> & t,
           const unsigned int file_version )
{
    typedef boost::multi_array<double,2> multi_array_;
    typedef typename multi_array_::size_type size_;
    size_ n0 = ( t.shape()[0] );
    ar << BOOST_SERIALIZATION_NVP( n0 );
    size_ n1 = ( t.shape()[1] );
    ar << BOOST_SERIALIZATION_NVP( n1 );
    ar << boost::serialization::make_array( t.data(),
                                            t.num_elements() );
}
コード例 #4
0
ファイル: serialization.hpp プロジェクト: feelpp/feelpp
void load( Archive & ar,
           boost::multi_array<double,2> & t,
           const unsigned int file_version )
{
    typedef boost::multi_array<double,2> multi_array_;
    typedef typename multi_array_::size_type size_;
    size_ n0;
    ar >> BOOST_SERIALIZATION_NVP( n0 );
    size_ n1;
    ar >> BOOST_SERIALIZATION_NVP( n1 );
    t.resize( boost::extents[n0][n1] );
    ar >> make_array( t.data(), t.num_elements() );
}
コード例 #5
0
  void save(handle const& loc,
	    boost::multi_array<ValueType, NumDims, Allocator> const& h,
	    const char* name)
  {
    datatype type = datatype_from<ValueType>::value();
    std::array<hsize_t, NumDims> extents;
    std::copy(h.shape(), h.shape() + NumDims, extents.begin());
    dataspace space = dataspace::create_simple(extents);

    ( link_exists(loc, name)
      ? dataset::open(loc, name)
      : dataset::create(loc, name, type, space) )
      .write(type, space, h.data());
  }
コード例 #6
0
    void CONetCDF4::writeData(const boost::multi_array<DataType, ndim> & _data,
                              const std::string                        & _varname,
                              std::size_t                                _record,
                              bool                                       _collective,
                              const std::vector<std::size_t>           * _start,
                              const std::vector<std::size_t>           * _count)
 {
    int grpid = this->getCurrentGroup();
    int varid = this->getVariable(_varname);
    std::size_t _array_size = 1;
    std::vector<std::size_t> _sstart, _scount;
    
    if (this->comm_server && _collective)
       CheckError(nc_var_par_access(grpid, varid, NC_COLLECTIVE));
    if (this->comm_server && !_collective)
       CheckError(nc_var_par_access(grpid, varid, NC_INDEPENDENT));
    
    this->getWriteDataInfos
       (_varname, _record, _array_size,  _sstart, _scount, _start, _count);
    this->writeData_(grpid, varid, _sstart, _scount, _data.data());
 }
コード例 #7
0
void fill(boost::multi_array<V1,NumDims,Allocator> &x, const V2 &v) {
    std::fill_n(x.data(), x.num_elements(), v);
}
コード例 #8
0
ファイル: multi_array.hpp プロジェクト: K-ballo/hpx
 void save(output_archive& ar, const boost::multi_array<T, N,
     Allocator>& marray, unsigned)
 {
     ar & make_array(marray.shape(), marray.num_dimensions());
     ar & make_array(marray.data(), marray.num_elements());
 }