15#include "libmesh/libmesh_common.h"
52 const std::vector<std::vector<T>>
_items;
64 : _n_rows(computeRowCount(items)), _n_cols(items.size()), _items(items)
67 for (
typename std::vector<std::vector<T>>::const_reverse_iterator iter =
_items.rbegin();
71 std::size_t n = iter->size();
79std::vector<std::vector<T>>
82 std::vector<std::vector<T>> output(_n_rows, std::vector<T>(_n_cols));
83 for (std::size_t row = 0; row < _n_rows; ++row)
84 for (std::size_t col = 0; col < _n_cols; ++col)
85 output[row][col] = computeValue(row, col);
93 std::vector<T> output(_n_cols);
94 for (std::size_t col = 0; col < _n_cols; ++col)
95 output[col] = computeValue(row, col);
103 mooseAssert(row < _n_rows,
"Row index out of range.");
104 mooseAssert(col < _n_cols,
"Column index out of range.");
105 return _items[col][(row / _denomenators[col]) % _moduli[col]];
112 std::size_t n_rows = 1;
113 for (
const auto & inner : items)
114 n_rows *= inner.size();
121template <
class T,
class W>
126 const std::vector<std::vector<W>> & weights);
139template <
typename T,
typename W>
141 const std::vector<std::vector<T>> & items,
const std::vector<std::vector<W>> & weights)
144 mooseAssert(items.size() == weights.size(),
145 "The supplied items and weights must be the same size.");
146 for (std::size_t i = 0; i < items.size(); ++i)
147 mooseAssert(items[i].size() == weights[i].size(),
148 "Internal vector of the supplied items and weights must be the same size.");
151template <
typename T,
typename W>
155 std::vector<W> output(this->_n_rows);
156 for (std::size_t i = 0; i < output.size(); ++i)
157 output[i] = computeWeight(i);
161template <
typename T,
typename W>
165 std::vector<W> vec = _weight.computeRow(row);
166 return std::accumulate(vec.begin(), vec.end(),
static_cast<W
>(1), std::multiplies<W>());