Definition at line 30 of file ArrayUtils.h.
◆ ReturnType
◆ createDataImpl() [1/2]
template<class T >
std::unique_ptr< OutputData< T > > ArrayUtils::CreateDataImpl::createDataImpl |
( |
const std::vector< T > & |
vec | ) |
|
|
staticprivate |
◆ createDataImpl() [2/2]
template<class T >
std::unique_ptr< OutputData< T > > ArrayUtils::CreateDataImpl::createDataImpl |
( |
const std::vector< std::vector< T >> & |
vec | ) |
|
|
staticprivate |
Definition at line 97 of file ArrayUtils.h.
99 auto result = std::make_unique<OutputData<T>>();
102 const size_t nrows = shape.first;
103 const size_t ncols = shape.second;
105 if (nrows == 0 || ncols == 0)
106 throw std::runtime_error(
107 "Error in ArrayUtils::createDataImpl: input argument contains empty dimensions");
109 result->addAxis(
FixedBinAxis(
"axis0", ncols, 0.0,
static_cast<double>(ncols)));
110 result->addAxis(
FixedBinAxis(
"axis1", nrows, 0.0,
static_cast<double>(nrows)));
113 for (
size_t row = 0; row < nrows; ++row) {
114 for (
size_t col = 0; col < ncols; ++col) {
115 size_t globalbin = nrows - row - 1 + col * nrows;
116 (*result)[globalbin] = vec[row][col];
std::pair< size_t, size_t > getShape(const T &data)
Returns shape nrows, ncols of 2D array.
References ArrayUtils::getShape().
◆ createData
Creates OutputData array from input vector.
Definition at line 61 of file ArrayUtils.h.
65 size == 1 || size == 2,
66 "Error in ArrayUtils::createData: invalid dimensionality or type of the input argument");
67 static_assert(std::is_same<CreateDataImpl::ReturnType<T>,
69 "Error in ArrayUtils::createData: invalid return type.");
static std::unique_ptr< OutputData< T > > createDataImpl(const std::vector< T > &vec)
The documentation for this class was generated from the following file: