Definition at line 35 of file ArrayUtils.h.
◆ ReturnType
◆ createDataImpl() [1/2]
template<class T >
std::unique_ptr< OutputData< T > > ArrayUtils::CreateDataImpl::createDataImpl |
( |
const std::vector< std::vector< T >> & |
vec | ) |
|
|
staticprivate |
Definition at line 101 of file ArrayUtils.h.
103 auto result = std::make_unique<OutputData<T>>();
106 const size_t nrows = shape.first;
107 const size_t ncols = shape.second;
109 if (nrows == 0 || ncols == 0)
110 throw std::runtime_error(
111 "Error in ArrayUtils::createDataImpl: input argument contains empty dimensions");
113 result->addAxis(
FixedBinAxis(
"axis0", ncols, 0.0,
static_cast<double>(ncols)));
114 result->addAxis(
FixedBinAxis(
"axis1", nrows, 0.0,
static_cast<double>(nrows)));
117 for (
size_t row = 0; row < nrows; ++row) {
118 for (
size_t col = 0; col < ncols; ++col) {
119 size_t globalbin = nrows - row - 1 + col * nrows;
120 (*result)[globalbin] = vec[row][col];
Axis with fixed bin size.
std::pair< size_t, size_t > getShape(const T &data)
Returns shape nrows, ncols of 2D array.
References ArrayUtils::getShape().
◆ createDataImpl() [2/2]
template<class T >
std::unique_ptr< OutputData< T > > ArrayUtils::CreateDataImpl::createDataImpl |
( |
const std::vector< T > & |
vec | ) |
|
|
staticprivate |
Definition at line 90 of file ArrayUtils.h.
92 auto result = std::make_unique<OutputData<T>>();
93 const size_t length = vec.size();
94 result->addAxis(
FixedBinAxis(
"axis0", length, 0.0,
static_cast<double>(length)));
95 result->setRawDataVector(vec);
◆ createData
Creates OutputData array from input vector.
Definition at line 65 of file ArrayUtils.h.
69 size == 1 || size == 2,
70 "Error in ArrayUtils::createData: invalid dimensionality or type of the input argument");
71 static_assert(std::is_same<CreateDataImpl::ReturnType<T>,
73 "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: