19 #include <momemta/ParameterSet.h> 20 #include <momemta/Module.h> 21 #include <momemta/Types.h> 22 #include <momemta/Utils.h> 60 auto tags = parameters.get<std::vector<InputTag>>(
"inputs");
62 m_terms.push_back(get<T>(v));
64 m_coefficients = parameters.get<std::vector<double>>(
"coefficients");
66 if (m_coefficients.size() == 0 || m_terms.size() == 0){
67 auto exception = std::invalid_argument(
"Tried to call LinearCombinator with an empty input.");
68 LOG(fatal) << exception.what();
71 if (m_coefficients.size() != m_terms.size()){
72 auto exception = std::invalid_argument(
"The Term and Coefficient lists passed to LinearCombinator have different sizes.");
73 LOG(fatal) << exception.what();
78 virtual Status
work()
override {
80 T temp_result = m_coefficients[0] * *m_terms[0];
81 for (std::size_t i = 1; i < m_terms.size(); i++)
82 temp_result += m_coefficients[i] * *m_terms[i];
84 *output = temp_result;
92 std::vector<double> m_coefficients;
93 std::vector<Value<T>> m_terms;
96 std::shared_ptr<T> output = produce<T>(
"output");
102 .Attr(
"coefficients:list(double)");
107 .Attr(
"coefficients:list(double)");
112 .Attr(
"coefficients:list(double)");
Performs linear combination of templated terms.
Parent class for all the modules.
A class encapsulating a lua table.
virtual Status work() override
Main function.
Module(PoolPtr pool, const std::string &name)
Constructor.