33 ProcMultiply(
const char *
name,
36 ~ProcMultiply()
override {}
38 void configure(ConfIterator iter,
unsigned int n)
override;
39 void eval(ValueIterator iter,
unsigned int n)
const override;
40 std::vector<double> deriv(
41 ValueIterator iter,
unsigned int n)
const override;
44 typedef std::vector<unsigned int>
Config;
47 std::vector<Config>
out;
52 ProcMultiply::ProcMultiply(
const char *
name,
59 std::back_inserter(
out));
62 void ProcMultiply::configure(ConfIterator iter,
unsigned int n)
67 for(
unsigned int i = 0;
i <
in;
i++)
68 iter++(Variable::FLAG_NONE);
70 for(
unsigned int i = 0;
i <
out.size();
i++)
71 iter << Variable::FLAG_NONE;
74 void ProcMultiply::eval(ValueIterator iter,
unsigned int n)
const 76 double *
values = (
double*)alloca(in *
sizeof(
double));
77 for(
double *
pos = values; iter; iter++,
pos++) {
80 <<
"Special input variable encountered " 86 for(std::vector<Config>::const_iterator
config =
out.begin();
89 for(std::vector<unsigned int>::const_iterator
var =
92 product *= values[*
var];
98 std::vector<double> ProcMultiply::deriv(
99 ValueIterator iter,
unsigned int n)
const 101 std::vector<double>
values;
102 std::vector<unsigned int> offsets;
103 unsigned int size = 0;
105 offsets.push_back(size);
107 values.push_back(*iter++);
112 for(std::vector<Config>::const_iterator
config =
out.begin();
114 for(
unsigned int i = 0;
i <
config->size();
i++) {
115 double product = 1.0;
116 for(
unsigned int j = 0; j <
config->size(); j++)
118 product *= values[(*config)[j]];
120 result[k * size + offsets[
i]] = product;