CLHEP 2.4.7.1
C++ Class Library for High Energy Physics
SymToArgAdaptor.icc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id:
3#include "SymToArgAdaptor.hh"
4#include <assert.h>
5#include <iostream>
6#include <cfloat>
7
8namespace Genfun {
9
10
11//FUNCTION_OBJECT_IMP(SymToArgAdaptor) Do it by hand here:
12
13template <class F>
14inline
16{
17 return AbsFunction::operator() (function);
18}
19
20template <class F>
21inline
23 return (SymToArgAdaptor<F> *) _clone();
24}
25
26template <class F>
27inline
29 return new SymToArgAdaptor<F>(*this);
30}
31template <class F>
32inline
34{ \
35 return AbsFunction::operator() (p); \
36}
37
38template<class F>
39inline
41 const AbsFunction & f_expression,
42 SymToArgAdaptor<F>::ScopedMethodPtr parameterFetchMethod,
43 const AbsFunction * p_expression):
44
45 _function(function.clone()),
46 _f_expression(f_expression.clone()),
47 _parameterFetchMethod(parameterFetchMethod),
48 _p_expression(p_expression->clone())
49
50{
51 _parameterFetchMethod(*_function).setLowerLimit(-DBL_MAX);
52 _parameterFetchMethod(*_function).setUpperLimit(+DBL_MAX);
53 assert(f_expression.dimensionality()==p_expression->dimensionality());
54}
55
56template <class F>
57inline
59 delete _function;
60 delete _f_expression;
61 delete _p_expression;
62}
63
64template <class F>
65inline
67 _function(right._function->clone()),
68 _f_expression(right._f_expression->clone()),
69 _parameterFetchMethod(right._parameterFetchMethod),
70 _p_expression(right._p_expression->clone())
71{
72 _parameterFetchMethod(*_function).setLowerLimit(-DBL_MAX);
73 _parameterFetchMethod(*_function).setUpperLimit(+DBL_MAX);
74}
75
76
77template <class F>
78inline
79double SymToArgAdaptor<F>::operator ()(double x) const
80{
81 std::cerr
82 << "Warning. SymToArgAdaptor called with scalar argument"
83 << std::endl;
84 assert(0);
85 return 0;
86}
87
88template <class F>
89inline
91 return _f_expression->dimensionality();
92}
93
94template <class F>
95inline
97 if (dimensionality()!= a.dimension()) {
98 std::cerr
99 << "Warning: SymToArgAdaptor function/argument dimension mismatch"
100 << std::endl;
101 assert(0);
102 return 0;
103 }
104
105 // First evaluate the sumbol.
106 double pVal= (*_p_expression)(a);
107
108 // Then set the associated parameter:
109 (_parameterFetchMethod(*_function)).setValue(pVal);
110
111 // Now evaluate the function:
112 return (*_function)((*_f_expression) (a));
113}
114} // end of namespace Genfun
115
116
virtual AbsFunction * clone() const =0
virtual double operator()(double argument) const =0
unsigned int dimension() const
Definition Argument.hh:61
virtual unsigned int dimensionality() const override
virtual double operator()(double argument) const override
Parameter &(F::* ScopedMethodPtr)()
SymToArgAdaptor(F &function, const AbsFunction &f_expression, ScopedMethodPtr parameterFetchMethod, const AbsFunction *p_expression)
Definition Abs.hh:14