CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
Main Page
Namespaces
Classes
Files
File List
File Members
GenericFunctions
CLHEP
GenericFunctions
CLHEP/GenericFunctions/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
14
namespace
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
42
typedef
FunctionNoop
Derivative
;
43
48
class
AbsFunction
{
49
50
public
:
51
52
// Default Constructor
53
AbsFunction
();
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
96
FunctionProduct
operator *
(
const
AbsFunction &op1,
const
AbsFunction &op2);
97
FunctionSum
operator +
(
const
AbsFunction &op1,
const
AbsFunction &op2);
98
FunctionDifference
operator -
(
const
AbsFunction &op1,
const
AbsFunction &op2);
99
FunctionQuotient
operator /
(
const
AbsFunction &op1,
const
AbsFunction &op2);
100
FunctionNegation
operator -
(
const
AbsFunction &op1);
101
102
ConstTimesFunction
operator *
(
double
c,
const
AbsFunction &op2);
103
ConstPlusFunction
operator +
(
double
c,
const
AbsFunction &op2);
104
ConstMinusFunction
operator -
(
double
c,
const
AbsFunction &op2);
105
ConstOverFunction
operator /
(
double
c,
const
AbsFunction &op2);
106
107
ConstTimesFunction
operator *
(
const
AbsFunction &op2,
double
c);
108
ConstPlusFunction
operator +
(
const
AbsFunction &op2,
double
c);
109
ConstPlusFunction
operator -
(
const
AbsFunction &op2,
double
c);
110
ConstTimesFunction
operator /
(
const
AbsFunction &op2,
double
c);
111
112
FunctionTimesParameter
operator *
(
const
AbsFunction &op1,
const
AbsParameter &op2);
113
FunctionPlusParameter
operator +
(
const
AbsFunction &op1,
const
AbsParameter &op2);
114
FunctionPlusParameter
operator -
(
const
AbsFunction &op1,
const
AbsParameter &op2);
115
FunctionTimesParameter
operator /
(
const
AbsFunction &op1,
const
AbsParameter &op2);
116
117
FunctionTimesParameter
operator *
(
const
AbsParameter &op1,
const
AbsFunction &op2);
118
FunctionPlusParameter
operator +
(
const
AbsParameter &op1,
const
AbsFunction &op2);
119
FunctionPlusParameter
operator -
(
const
AbsParameter &op1,
const
AbsFunction &op2);
120
FunctionTimesParameter
operator /
(
const
AbsParameter &op1,
const
AbsFunction &op2);
121
122
FunctionConvolution
convolve
(
const
AbsFunction &op1,
const
AbsFunction &op2,
double
x0,
double
x1);
123
FunctionDirectProduct
operator %
(
const
AbsFunction &op1,
const
AbsFunction &op2);
124
125
typedef
const
AbsFunction
&
GENFUNCTION
;
126
127
}
// namespace Genfun
128
129
130
//----------------------------------------------------------------------------
131
//
132
// This macro does all the ugly boilerplate. For reference I will lis what
133
// it is doing:
134
//
135
// 1). It uses the base class function composition operator. It would be
136
// nice to just use the
137
//
138
// using AbsFunction::operator();
139
//
140
// directive but unfortunately this is compiler-dependent!
141
//
142
143
144
#define FUNCTION_OBJECT_DEF(classname) \
145
public: \
146
virtual FunctionComposition operator()(const AbsFunction &function) const; \
147
virtual ParameterComposition operator()(const AbsParameter &p) const; \
148
virtual classname *clone() const; \
149
private:
150
151
//----------------------------------------------------------------------------
152
//
153
// This macro implements the ugly boilerplate
154
//
155
156
#define FUNCTION_OBJECT_IMP(classname) \
157
inline FunctionComposition classname::operator()(const AbsFunction & function) const\
158
{ \
159
return AbsFunction::operator() (function); \
160
} \
161
inline ParameterComposition classname::operator()(const AbsParameter & p) const\
162
{ \
163
return AbsFunction::operator() (p); \
164
} \
165
inline classname *classname::clone() const \
166
{ \
167
return new classname(*this); \
168
}
169
170
171
//----------------------------------------------------------------------------
172
173
174
#include "
CLHEP/GenericFunctions/FunctionProduct.hh
"
175
#include "
CLHEP/GenericFunctions/FunctionSum.hh
"
176
#include "
CLHEP/GenericFunctions/FunctionDifference.hh
"
177
#include "
CLHEP/GenericFunctions/FunctionQuotient.hh
"
178
#include "
CLHEP/GenericFunctions/FunctionConvolution.hh
"
179
#include "
CLHEP/GenericFunctions/FunctionNegation.hh
"
180
#include "
CLHEP/GenericFunctions/FunctionDirectProduct.hh
"
181
#include "
CLHEP/GenericFunctions/FunctionComposition.hh
"
182
#include "
CLHEP/GenericFunctions/ConstPlusFunction.hh
"
183
#include "
CLHEP/GenericFunctions/ConstTimesFunction.hh
"
184
#include "
CLHEP/GenericFunctions/ConstMinusFunction.hh
"
185
#include "
CLHEP/GenericFunctions/ConstOverFunction.hh
"
186
#include "
CLHEP/GenericFunctions/FunctionPlusParameter.hh
"
187
#include "
CLHEP/GenericFunctions/FunctionTimesParameter.hh
"
188
#include "
CLHEP/GenericFunctions/FunctionNoop.hh
"
189
#include "
CLHEP/GenericFunctions/ParameterComposition.hh
"
190
191
#endif
Generated on Sun Jun 17 2012 08:08:26 for CLHEP by
1.8.1.1