Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JFunctionObject1D.hh
Go to the documentation of this file.
1#ifndef __JFUNCTIONOBJECT1D__
2#define __JFUNCTIONOBJECT1D__
3
5#include "JLang/JClass.hh"
6#include "JMath/JZero.hh"
10
11
12/**
13 * \author mdejong
14 */
15
16namespace JTOOLS {}
17namespace JPP { using namespace JTOOLS; }
18
19namespace JTOOLS {
20
21 using JIO::JReader;
22 using JIO::JWriter;
23
24
25 /**
26 * Template implementation of function object in one dimension using an external function.
27 *
28 * This class implements the JFunction1D interface.
29 */
30 template<class JArgument_t, class JResult_t>
32 public JFunction1D<JArgument_t, JResult_t>
33 {
34 public:
35
39
41
42
43 /**
44 * Constructor.
45 *
46 * \param function pointer to function
47 */
50 __f(function)
51 {}
52
53
54 /**
55 * Function value evaluation.
56 *
57 * \param pX pointer to abscissa values
58 * \return function value
59 */
60 virtual result_type evaluate(const argument_type* pX) const override
61 {
62 return __f(*pX);
63 }
64
65
66 protected:
67 /**
68 * Function compilation.
69 */
70 virtual void do_compile() override
71 {}
72
73
75 };
76
77
78 /**
79 * Template implementation of function object in one dimension.
80 *
81 * This class implements the JFunction1D interface.
82 */
83 template<class JArgument_t, class JResult_t>
85 public JFunction1D<JArgument_t, JResult_t>
86 {
87 public:
88
89
93
94
95 /**
96 * Default constructor.
97 */
102
103
104 /**
105 * Constructor.
106 *
107 * \param y constant value
108 */
111 function(new JConstantFunction1D<JArgument_t, JResult_t>(y))
112 {}
113
114
115 /**
116 * Constructor.
117 *
118 * \param f pointer to external function
119 */
122 function(new JExternalFunction1D<JArgument_t, JResult_t>(f))
123 {}
124
125
126 /**
127 * Function value evaluation.
128 *
129 * \param pX pointer to abscissa values
130 * \return function value
131 */
132 virtual result_type evaluate(const argument_type* pX) const override
133 {
134 return function->evaluate(pX);
135 }
136
137
138 protected:
139 /**
140 * Function compilation.
141 */
142 virtual void do_compile() override
143 {
144 function->compile();
145 }
146
147
149 };
150}
151
152#endif
Definition of zero value for any class.
Interface for binary input.
Interface for binary output.
The template JSinglePointer class can be used to hold a pointer to an object.
Template implementation of function object in one dimension returning a constant value.
Template implementation of function object in one dimension using an external function.
virtual void do_compile() override
Function compilation.
result_type(*) pointerToFunction(const argument_type)
JExternalFunction1D(pointerToFunction function)
Constructor.
JFunction1D< JArgument_t, JResult_t > function_type
function_type::result_type result_type
virtual result_type evaluate(const argument_type *pX) const override
Function value evaluation.
function_type::argument_type argument_type
Template implementation of function object in one dimension.
JFunction1D< JArgument_t, JResult_t > function_type
virtual void do_compile() override
Function compilation.
JFunctionObject1D(result_type(*f)(const argument_type))
Constructor.
function_type::argument_type argument_type
virtual result_type evaluate(const argument_type *pX) const override
Function value evaluation.
JLANG::JSinglePointer< function_type > function
function_type::result_type result_type
JFunctionObject1D(typename JLANG::JClass< result_type >::argument_type y)
Constructor.
JFunctionObject1D()
Default constructor.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
JArgument< T >::argument_type argument_type
Definition JClass.hh:82
Template definition of function object interface in one dimension.
functional_type::result_type result_type
functional_type::argument_type argument_type