32 #ifndef MCKL_CORE_ESTIMATOR_HPP 33 #define MCKL_CORE_ESTIMATOR_HPP 44 template <
typename T,
typename... Args>
52 template <
typename Eval>
61 template <
typename Eval>
62 std::enable_if_t<!std::is_convertible<Eval, int>::value>
estimate(
65 eval_ = std::forward<Eval>(eval);
70 template <
typename OutputIter>
72 OutputIter first, std::size_t cut = 0, std::size_t thin = 1)
const 74 const std::size_t n = this->num_iter();
75 const std::size_t d = this->dim();
81 thin = thin < 1 ? 1 : thin;
83 return this->read_estimate(cut, first);
92 add(d, this->row_data(cut), sum.data(), sum.data());
96 mul(d, static_cast<T>(1.0l / n), sum.data(), sum.data());
98 return std::copy(sum.begin(), sum.end(), first);
102 template <
typename... CallArgs>
106 "**Estimator::eval** used with an invalid evaluation object");
108 eval_(std::forward<CallArgs>(args)...);
112 std::function<void(Args...)> eval_;
119 #endif // MCKL_CORE_ESTIMATOR_HPP Estimate matrix for iterative Monte Carlo algorithms.
void mul(std::size_t n, const float *a, const float *b, float *y)
void eval(CallArgs &&... args)
#define MCKL_PUSH_CLANG_WARNING(warning)
std::vector< T, Alloc > Vector
std::vector with Allocator as the default allocator
#define MCKL_POP_CLANG_WARNING
Estimator(std::size_t dim)
Estimator for iterative Monte Carlo algorithms.
std::enable_if_t<!std::is_convertible< Eval, int >::value > estimate(Eval &&eval)
Set a new estimate evaluation method.
Estimator(std::size_t dim, Eval &&eval)
OutputIter average(OutputIter first, std::size_t cut=0, std::size_t thin=1) const
Get the average of estimates after cut iterations using every thin elements.
void runtime_assert(bool cond, const char *msg, bool soft=false)
void add(std::size_t n, const float *a, const float *b, float *y)