Jpp
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"
7 #include "JIO/JSerialisable.hh"
8 #include "JTools/JFunctional.hh"
10 
11 
12 /**
13  * \author mdejong
14  */
15 
16 namespace JTOOLS {}
17 namespace JPP { using namespace JTOOLS; }
18 
19 namespace 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  */
49  function_type(),
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
61  {
62  return __f(*pX);
63  }
64 
65 
66  protected:
67  /**
68  * Function compilation.
69  */
70  virtual void do_compile()
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  */
99  function_type(),
100  function()
101  {}
102 
103 
104  /**
105  * Constructor.
106  *
107  * \param y constant value
108  */
110  function_type(),
111  function(new JConstantFunction1D<JArgument_t, JResult_t>(y))
112  {}
113 
114 
115  /**
116  * Constructor.
117  *
118  * \param f pointer to external function
119  */
121  function_type(),
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
133  {
134  return function->evaluate(pX);
135  }
136 
137 
138  protected:
139  /**
140  * Function compilation.
141  */
142  virtual void do_compile()
143  {
144  function->compile();
145  }
146 
147 
149  };
150 }
151 
152 #endif
JIO::JReader
Interface for binary input.
Definition: JSerialisable.hh:62
JTOOLS::pX
pX
Definition: JPolint.hh:625
JLANG::JSinglePointer
The template JSinglePointer class can be used to hold a pointer to an object.
Definition: JSinglePointer.hh:24
JTOOLS::JFunctionObject1D::result_type
function_type::result_type result_type
Definition: JFunctionObject1D.hh:92
JZero.hh
JTOOLS::JExternalFunction1D::__f
pointerToFunction __f
Definition: JFunctionObject1D.hh:74
JTOOLS::JConstantFunction1D
Template implementation of function object in one dimension returning a constant value.
Definition: JConstantFunction1D.hh:26
JTOOLS::JExternalFunction1D::pointerToFunction
result_type(* pointerToFunction)(const argument_type)
Definition: JFunctionObject1D.hh:40
JTOOLS::JExternalFunction1D
Template implementation of function object in one dimension using an external function.
Definition: JFunctionObject1D.hh:31
JSinglePointer.hh
JTOOLS::JExternalFunction1D::function_type
JFunction1D< JArgument_t, JResult_t > function_type
Definition: JFunctionObject1D.hh:36
JTOOLS::JFunctionObject1D::function_type
JFunction1D< JArgument_t, JResult_t > function_type
Definition: JFunctionObject1D.hh:90
JLANG::JClass::argument_type
JArgument< T >::argument_type argument_type
Definition: JClass.hh:82
JTOOLS::JFunctional::result_type
JResult_t result_type
Definition: JFunctional.hh:87
JTOOLS::JFunctionObject1D
Template implementation of function object in one dimension.
Definition: JFunctionObject1D.hh:84
JTOOLS::JFunctionObject1D::JFunctionObject1D
JFunctionObject1D(result_type(*f)(const argument_type))
Constructor.
Definition: JFunctionObject1D.hh:120
JTOOLS::JFunctionObject1D::JFunctionObject1D
JFunctionObject1D(typename JLANG::JClass< result_type >::argument_type y)
Constructor.
Definition: JFunctionObject1D.hh:109
JTOOLS::JFunctionObject1D::JFunctionObject1D
JFunctionObject1D()
Default constructor.
Definition: JFunctionObject1D.hh:98
JTOOLS::JExternalFunction1D::argument_type
function_type::argument_type argument_type
Definition: JFunctionObject1D.hh:37
JTOOLS::JFunctional::argument_type
JArgument_t argument_type
Definition: JFunctional.hh:84
JConstantFunction1D.hh
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JTOOLS::JFunctionObject1D::do_compile
virtual void do_compile()
Function compilation.
Definition: JFunctionObject1D.hh:142
JTOOLS::JFunction1D
Template definition of function object interface in one dimension.
Definition: JFunctional.hh:317
JTOOLS::JFunctionObject1D::argument_type
function_type::argument_type argument_type
Definition: JFunctionObject1D.hh:91
JSerialisable.hh
JIO::JWriter
Interface for binary output.
Definition: JSerialisable.hh:130
JTOOLS::JExternalFunction1D::evaluate
virtual result_type evaluate(const argument_type *pX) const
Function value evaluation.
Definition: JFunctionObject1D.hh:60
JTOOLS::JFunctionObject1D::function
JLANG::JSinglePointer< function_type > function
Definition: JFunctionObject1D.hh:148
JTOOLS::JExternalFunction1D::JExternalFunction1D
JExternalFunction1D(pointerToFunction function)
Constructor.
Definition: JFunctionObject1D.hh:48
JFunctional.hh
JTOOLS::JFunctionObject1D::evaluate
virtual result_type evaluate(const argument_type *pX) const
Function value evaluation.
Definition: JFunctionObject1D.hh:132
JTOOLS::JExternalFunction1D::result_type
function_type::result_type result_type
Definition: JFunctionObject1D.hh:38
JClass.hh
JTOOLS::JExternalFunction1D::do_compile
virtual void do_compile()
Function compilation.
Definition: JFunctionObject1D.hh:70
JTOOLS
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
Definition: JAbstractCollection.hh:9
JTOOLS::JFunction1D::argument_type
functional_type::argument_type argument_type
Definition: JFunctional.hh:323
JTOOLS::JFunction1D::result_type
functional_type::result_type result_type
Definition: JFunctional.hh:324