CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
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
12#include "CLHEP/GenericFunctions/Argument.hh"
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;
25 class FunctionDifference;
26 class FunctionQuotient;
27 class FunctionNegation;
28 class FunctionConvolution;
29 class FunctionDirectProduct;
30 class FunctionComposition;
31 class ConstPlusFunction;
32 class ConstTimesFunction;
33 class ConstMinusFunction;
34 class ConstOverFunction;
35 class FunctionPlusParameter;
36 class FunctionTimesParameter;
37 class FunctionNumDeriv;
38 class Variable;
39 class FunctionNoop;
40 class ParameterComposition;
41
43
44 /**
45 * @author
46 * @ingroup genfun
47 */
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:
72 virtual FunctionComposition operator () (const AbsFunction &f) const;
73
74 // Parameter composition. Do not attempt to override:
75 virtual ParameterComposition operator() ( const AbsParameter &p) const;
76
77 // Derivative, (All functions) (do not override)
78 Derivative derivative(const Variable &v) const;
79
80 // Derivative (1D functions only) (do not override)
81 Derivative prime() const;
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
96FunctionProduct operator * (const AbsFunction &op1, const AbsFunction &op2);
97FunctionSum operator + (const AbsFunction &op1, const AbsFunction &op2);
98FunctionDifference operator - (const AbsFunction &op1, const AbsFunction &op2);
99FunctionQuotient operator / (const AbsFunction &op1, const AbsFunction &op2);
100FunctionNegation operator - (const AbsFunction &op1);
101
102ConstTimesFunction operator * (double c, const AbsFunction &op2);
103ConstPlusFunction operator + (double c, const AbsFunction &op2);
104ConstMinusFunction operator - (double c, const AbsFunction &op2);
105ConstOverFunction operator / (double c, const AbsFunction &op2);
106
107ConstTimesFunction operator * (const AbsFunction &op2, double c);
108ConstPlusFunction operator + (const AbsFunction &op2, double c);
109ConstPlusFunction operator - (const AbsFunction &op2, double c);
110ConstTimesFunction operator / (const AbsFunction &op2, double c);
111
112FunctionTimesParameter operator * (const AbsFunction &op1, const AbsParameter &op2);
113FunctionPlusParameter operator + (const AbsFunction &op1, const AbsParameter &op2);
114FunctionPlusParameter operator - (const AbsFunction &op1, const AbsParameter &op2);
115FunctionTimesParameter operator / (const AbsFunction &op1, const AbsParameter &op2);
116
117FunctionTimesParameter operator * (const AbsParameter &op1, const AbsFunction &op2);
118FunctionPlusParameter operator + (const AbsParameter &op1, const AbsFunction &op2);
119FunctionPlusParameter operator - (const AbsParameter &op1, const AbsFunction &op2);
120FunctionTimesParameter operator / (const AbsParameter &op1, const AbsFunction &op2);
121
122FunctionConvolution convolve (const AbsFunction &op1, const AbsFunction &op2, double x0, double x1);
123FunctionDirectProduct operator % (const AbsFunction &op1, const AbsFunction &op2);
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
159#include "CLHEP/GenericFunctions/FunctionProduct.hh"
160#include "CLHEP/GenericFunctions/FunctionSum.hh"
161#include "CLHEP/GenericFunctions/FunctionDifference.hh"
162#include "CLHEP/GenericFunctions/FunctionQuotient.hh"
163#include "CLHEP/GenericFunctions/FunctionConvolution.hh"
164#include "CLHEP/GenericFunctions/FunctionNegation.hh"
165#include "CLHEP/GenericFunctions/FunctionDirectProduct.hh"
166#include "CLHEP/GenericFunctions/FunctionComposition.hh"
167#include "CLHEP/GenericFunctions/ConstPlusFunction.hh"
168#include "CLHEP/GenericFunctions/ConstTimesFunction.hh"
169#include "CLHEP/GenericFunctions/ConstMinusFunction.hh"
170#include "CLHEP/GenericFunctions/ConstOverFunction.hh"
171#include "CLHEP/GenericFunctions/FunctionPlusParameter.hh"
172#include "CLHEP/GenericFunctions/FunctionTimesParameter.hh"
173#include "CLHEP/GenericFunctions/FunctionNoop.hh"
174#include "CLHEP/GenericFunctions/ParameterComposition.hh"
175
176#endif
virtual Derivative partial(unsigned int) const
Definition: AbsFunction.cc:40
virtual unsigned int dimensionality() const
Definition: AbsFunction.cc:79
virtual bool hasAnalyticDerivative() const
Definition: AbsFunction.hh:84
virtual AbsFunction * clone() const =0
Derivative derivative(const Variable &v) const
Definition: AbsFunction.cc:46
virtual ~AbsFunction()
Definition: AbsFunction.cc:26
Derivative prime() const
Definition: AbsFunction.cc:50
virtual double operator()(double argument) const =0
void f(void g())
Definition: excDblThrow.cc:38
Definition: Abs.hh:14
FunctionQuotient operator/(const AbsFunction &op1, const AbsFunction &op2)
Definition: AbsFunction.cc:67
FunctionNoop Derivative
Definition: AbsFunction.hh:42
FunctionDirectProduct operator%(const AbsFunction &op1, const AbsFunction &op2)
Definition: AbsFunction.cc:83
FunctionSum operator+(const AbsFunction &op1, const AbsFunction &op2)
Definition: AbsFunction.cc:55
FunctionProduct operator*(const AbsFunction &op1, const AbsFunction &op2)
Definition: AbsFunction.cc:63
FunctionConvolution convolve(const AbsFunction &op1, const AbsFunction &op2, double x0, double x1)
Definition: AbsFunction.cc:71
FunctionDifference operator-(const AbsFunction &op1, const AbsFunction &op2)
Definition: AbsFunction.cc:59
const AbsFunction & GENFUNCTION
Definition: AbsFunction.hh:125