本文整理汇总了C++中boost::multi_array::data方法的典型用法代码示例。如果您正苦于以下问题:C++ multi_array::data方法的具体用法?C++ multi_array::data怎么用?C++ multi_array::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::multi_array
的用法示例。
在下文中一共展示了multi_array::data方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
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: precompute
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: save
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: load
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: save
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: CheckError
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: fill
void fill(boost::multi_array<V1,NumDims,Allocator> &x, const V2 &v) {
std::fill_n(x.data(), x.num_elements(), v);
}
示例8: save
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());
}