本文整理汇总了C++中Array2D::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ Array2D::copy方法的具体用法?C++ Array2D::copy怎么用?C++ Array2D::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array2D
的用法示例。
在下文中一共展示了Array2D::copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add
// special add for Array2d<Real>
// Array2D needs a special add that cannot be implemented in the macro because
// we need to call the function copy(), or otherwise we only get references
void Pool::add(const string& name, const Array2D<Real>& value, bool validityCheck) {
/* first check if the pool has ever seen this key before, if it has, we can
* just add it, if not, we need to run some validation tests */
{
MutexLocker lock(mutexArray2DReal);
if (validityCheck && !isValid(value)) {
throw EssentiaException("Pool::add array contains invalid numbers (NaN or inf)");
}
if (_poolArray2DReal.find(name) != _poolArray2DReal.end()) {
_poolArray2DReal[name].push_back(value.copy());
return;
}
}
GLOBAL_LOCK
validateKey(name);
_poolArray2DReal[name].push_back(value.copy());
}
示例2: create
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Creates a raster from raw data
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
void LSDSoilHydroRaster::create(int nrows, int ncols, float xmin, float ymin,
float cellsize, float ndv, Array2D<float> data)
{
NRows = nrows;
NCols = ncols;
XMinimum = xmin;
YMinimum = ymin;
DataResolution = cellsize;
NoDataValue = ndv;
RasterData = data.copy();
if (RasterData.dim1() != NRows)
{
cout << "LSDSoilHydroRaster dimension of data is not the same as stated in NRows!" << endl;
exit(EXIT_FAILURE);
}
if (RasterData.dim2() != NCols)
{
cout << "LSDSoilHydroRaster dimension of data is not the same as stated in NCols!" << endl;
exit(EXIT_FAILURE);
}
}