CLHEP 2.4.7.1
C++ Class Library for High Energy Physics
AbsFunction.hh
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: AbsFunction.hh,v 1.3 2007/01/21 20:20:40 boudreau Exp $
3//------------------------AbsFunction-----------------------------------//
4// //
5// AbsFunction, base class for function objects //
6// Joe Boudreau, Petar Maksimovic //
7// Nov 1999 //
8// //
9//----------------------------------------------------------------------//
10#ifndef AbsFunction_h
11#define AbsFunction_h 1
13
14namespace Genfun {
15
16 class AbsParameter;
17
18 //-----------------------------------------------------------------------//
19 // Exact return type of arithmentic operations. To the user, the return //
20 // type is GENFUNCTION, or const AbsFunction &. //
21 //-----------------------------------------------------------------------//
22
23 class FunctionProduct;
24 class FunctionSum;
26 class FunctionQuotient;
27 class FunctionNegation;
37 class FunctionNumDeriv;
38 class Variable;
39 class FunctionNoop;
41
43
49
50 public:
51
52 // Default Constructor
54
55 // Copy Constructor:
56 AbsFunction(const AbsFunction &right);
57
58 // Destructor
59 virtual ~AbsFunction();
60
61 // Function value: N-dimensional functions must override these:
62 virtual unsigned int dimensionality() const; // returns 1;
63
64 // Function value
65 virtual double operator() (double argument) const=0;
66 virtual double operator() (const Argument &argument) const=0;
67
68 // Every function must override this:
69 virtual AbsFunction * clone() const=0;
70
71 // Function composition. Do not attempt to override:
73
74 // Parameter composition. Do not attempt to override:
76
77 // Derivative, (All functions) (do not override)
79
80 // Derivative (1D functions only) (do not override)
82
83 // Does this function have an analytic derivative?
84 virtual bool hasAnalyticDerivative() const {return false;}
85
86 // Derivative. Overriders may be provided, numerical method by default!
87 virtual Derivative partial(unsigned int) const;
88
89 private:
90
91 // It is illegal to assign a function.
92 const AbsFunction & operator=(const AbsFunction &right);
93
94 };
95
101
106
111
116
121
122FunctionConvolution convolve (const AbsFunction &op1, const AbsFunction &op2, double x0, double x1);
124
125typedef const AbsFunction & GENFUNCTION;
126
127} // namespace Genfun
128
129
130//----------------------------------------------------------------------------
131//
132// These macros do all the ugly boilerplate.
133//
134//----------------------------------------------------------------------------
135
136
137
138
139
140
141// A more modern way to accomplish this, which is slicker:
142
143#define FUNCTION_OBJECT_DEF(classname) \
144public: \
145 using Genfun::AbsFunction::operator(); \
146 virtual classname *clone() const override; \
147private:
148
149#define FUNCTION_OBJECT_IMP(classname) \
150inline classname *classname::clone() const \
151{ \
152 return new classname(*this); \
153}
154
155
156//----------------------------------------------------------------------------
157
158
175
176#endif
AbsFunction(const AbsFunction &right)
virtual bool hasAnalyticDerivative() const
virtual AbsFunction * clone() const =0
virtual ~AbsFunction()
Derivative derivative(const Variable &v) const
virtual Derivative partial(unsigned int) const
virtual unsigned int dimensionality() const
Derivative prime() const
virtual double operator()(double argument) const =0
Definition Abs.hh:14
FunctionQuotient operator/(const AbsFunction &op1, const AbsFunction &op2)
FunctionNoop Derivative
FunctionDirectProduct operator%(const AbsFunction &op1, const AbsFunction &op2)
FunctionSum operator+(const AbsFunction &op1, const AbsFunction &op2)
FunctionProduct operator*(const AbsFunction &op1, const AbsFunction &op2)
FunctionConvolution convolve(const AbsFunction &op1, const AbsFunction &op2, double x0, double x1)
FunctionDifference operator-(const AbsFunction &op1, const AbsFunction &op2)
const AbsFunction & GENFUNCTION