CMS 3D CMS Logo

formulaUnaryMinusEvaluator.h
Go to the documentation of this file.
1 #ifndef CommonTools_Utils_formulaUnaryMinusEvaluator_h
2 #define CommonTools_Utils_formulaUnaryMinusEvaluator_h
3 // -*- C++ -*-
4 //
5 // Package: CommonTools/Utils
6 // Class : formulaUnaryMinusEvaluator
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  explicit UnaryMinusEvaluator(std::shared_ptr<EvaluatorBase> iArg):
37  EvaluatorBase(Precedence::kUnaryMinusOperator ),
38  m_arg(std::move(iArg)) {}
39 
40  // ---------- const member functions ---------------------
41  double evaluate(double const* iVariables, double const* iParameters) const final {
42  return -1. * m_arg->evaluate(iVariables,iParameters) ;
43  }
44  std::vector<std::string> abstractSyntaxTree() const final {
45  auto ret = shiftAST(m_arg->abstractSyntaxTree());
46  ret.emplace(ret.begin(), "unary minus");
47  return ret;
48  }
49  private:
51 
52  const UnaryMinusEvaluator& operator=(const UnaryMinusEvaluator&) = delete;
53 
54  // ---------- member data --------------------------------
55  std::shared_ptr<EvaluatorBase> m_arg;
56  };
57  }
58 }
59 
60 
61 #endif
double evaluate(double const *iVariables, double const *iParameters) const final
std::vector< std::string > shiftAST(std::vector< std::string > child)
const UnaryMinusEvaluator & operator=(const UnaryMinusEvaluator &)=delete
std::vector< std::string > abstractSyntaxTree() const final
fixed size matrix
UnaryMinusEvaluator(std::shared_ptr< EvaluatorBase > iArg)
std::shared_ptr< EvaluatorBase > m_arg
def move(src, dest)
Definition: eostools.py:510