23 using namespace PhysicsTools;
32 ~ProcForeach()
override {}
34 void configure(ConfIterator iter,
unsigned int n)
override;
35 ConfigCtx::Context *configureLoop(ConfigCtx::Context *ctx,
36 ConfigCtx::iterator
begin,
37 ConfigCtx::iterator cur,
38 ConfigCtx::iterator
end)
override;
40 void eval(ValueIterator iter,
unsigned int n)
const override;
41 std::vector<double> deriv(ValueIterator iter,
unsigned int n)
const override;
42 LoopStatus
loop(
double *
output,
int *conf,
unsigned int nOutput, LoopCtx &ctx,
unsigned int &nOffset)
const override;
46 ConfContext(
unsigned int origin,
unsigned int count) : origin(origin), count(count) {}
47 ~ConfContext()
override {}
61 void ProcForeach::configure(ConfIterator iter,
unsigned int n) {
62 iter << Variable::FLAG_NONE;
64 iter << iter++(Variable::FLAG_MULTIPLE);
68 ConfigCtx::iterator
begin,
69 ConfigCtx::iterator cur,
70 ConfigCtx::iterator
end) {
71 ConfContext *ctx =
dynamic_cast<ConfContext *
>(ctx_);
73 return new ConfContext(cur - begin + 1,
count);
75 for (ConfigCtx::iterator iter = cur; iter !=
end; iter++) {
76 iter->mask = Variable::FLAG_ALL;
77 iter->origin = ctx->origin;
86 void ProcForeach::eval(ValueIterator iter,
unsigned int n)
const {
87 auto const offset = iter.loopCtx().offset();
90 auto &loopSize = iter.loopCtx().size();
92 unsigned int size = iter.size();
102 std::vector<double> ProcForeach::deriv(ValueIterator iter,
unsigned int n)
const {
103 auto const offset = iter.loopCtx().offset();
104 std::vector<unsigned int>
offsets;
105 unsigned int in = 0,
out = 0;
107 offsets.push_back(in +
offset);
108 in += (iter++).
size();
112 std::vector<double>
result((
out + 1) * in, 0.0);
113 for (
unsigned int i = 0;
i <
out;
i++)
114 result[(
i + 1) * in + offsets[
i]] = 1.0;
120 double *
output,
int *conf,
unsigned int nOutput, LoopCtx &ctx,
unsigned int &nOffset)
const {
121 auto &
index = ctx.index();
122 bool endIteration =
false;
127 auto &
offset = ctx.offset();
128 auto &size = ctx.size();
130 if (
offset == 0 && !endIteration) {
131 for (
int cur = *conf + size; nOutput--; cur +=
size)
140 }
else if (
offset > size) {
constexpr char const *const kStop
tuple size
Write out results.