22 "The number of rows for each loop of parameters. The first number represents the outermost " 26 "Sets of distribution names to be sampled. Each set defines the parameters for the nested " 27 "loop, with the first set being the outermost loop.");
35 const auto & dnames = getParam<std::vector<std::vector<DistributionName>>>(
"distributions");
36 const auto & nrows = getParam<std::vector<dof_id_type>>(
"num_rows");
37 if (dnames.size() != nrows.size())
39 "There must be a set of distributions for each loop defined by 'num_rows'.");
42 const std::size_t nloop = dnames.size();
43 std::vector<std::size_t> loop_index;
45 for (
const auto &
name : dnames[n])
48 loop_index.push_back(n);
52 std::vector<dof_id_type> loop_mod(nloop);
53 std::partial_sum(nrows.rbegin(), nrows.rend(), loop_mod.rbegin(), std::multiplies<dof_id_type>());
54 loop_mod.erase(loop_mod.begin());
55 loop_mod.push_back(1);
62 setNumberOfRows(std::accumulate(nrows.begin(), nrows.end(), 1, std::multiplies<dof_id_type>()));
69 const auto mod =
_col_mod[col_index];
70 const dof_id_type target_row = std::floor(row_index / mod) * mod;
void setNumberOfRows(dof_id_type n_rows)
static InputParameters validParams()
static InputParameters validParams()
void paramError(const std::string ¶m, Args... args) const
NestedMonteCarloSampler(const InputParameters ¶meters)
std::vector< const Distribution * > _distributions
Storage for distribution objects to be utilized.
std::vector< dof_id_type > _col_mod
Helper for determining the target row for the given column index: target_row = std::floor(row_index /...
registerMooseObjectAliased("StochasticToolsApp", NestedMonteCarloSampler, "NestedMonteCarlo")
const std::string & name() const
Real getRand(std::size_t n, unsigned int index=0) const
virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override
Return the sample for the given row and column.
const Distribution & getDistributionByName(const DistributionName &name) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void setNumberOfCols(dof_id_type n_cols)
IntRange< T > make_range(T beg, T end)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
auto index_range(const T &sizable)
dof_id_type getNumberOfCols() const
A class used to perform nested Monte Carlo Sampling.