CMS 3D CMS Logo

formulaFunctionOneArgEvaluator.h
Go to the documentation of this file.
1 #ifndef CommonTools_Utils_formulaFunctionOneArgEvaluator_h
2 #define CommonTools_Utils_formulaFunctionOneArgEvaluator_h
3 // -*- C++ -*-
4 //
5 // Package: CommonTools/Utils
6 // Class : formulaFunctionOneArgEvaluator
7 //
16 //
17 // Original Author: Christopher Jones
18 // Created: Wed, 23 Sep 2015 17:41:33 GMT
19 //
20 
21 // system include files
22 #include <memory>
23 #include <functional>
24 
25 // user include files
26 #include "formulaEvaluatorBase.h"
27 
28 // forward declarations
29 
30 namespace reco {
31  namespace formula {
33  {
34 
35  public:
36  template<typename T>
37  explicit FunctionOneArgEvaluator(std::shared_ptr<EvaluatorBase> iArg, T iFunc):
38  m_arg(std::move(iArg)),
39  m_function(iFunc) {}
40 
41  // ---------- const member functions ---------------------
42  double evaluate(double const* iVariables, double const* iParameters) const final {
43  return m_function( m_arg->evaluate(iVariables,iParameters) );
44  }
45  std::vector<std::string> abstractSyntaxTree() const final {
46  auto ret = shiftAST(m_arg->abstractSyntaxTree());
47  ret.emplace(ret.begin(), "func 1 arg");
48  return ret;
49  }
50  private:
52 
54 
55  // ---------- member data --------------------------------
56  std::shared_ptr<EvaluatorBase> m_arg;
57  std::function<double(double)> m_function;
58  };
59  }
60 }
61 
62 
63 #endif
const FunctionOneArgEvaluator & operator=(const FunctionOneArgEvaluator &)=delete
double evaluate(double const *iVariables, double const *iParameters) const final
std::vector< std::string > shiftAST(std::vector< std::string > child)
std::vector< std::string > abstractSyntaxTree() const final
FunctionOneArgEvaluator(std::shared_ptr< EvaluatorBase > iArg, T iFunc)
fixed size matrix
long double T
def move(src, dest)
Definition: eostools.py:510