Jpp  18.0.1-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 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  */
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 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
function_type::argument_type argument_type
Interface for binary output.
JExternalFunction1D(pointerToFunction function)
Constructor.
result_type(* pointerToFunction)(const argument_type)
functional_type::argument_type argument_type
Definition: JFunctional.hh:323
o $QUALITY_ROOT d $DEBUG!CHECK_EXIT_CODE JPlot1D f
Definition: JDataQuality.sh:76
JFunction1D< JArgument_t, JResult_t > function_type
function_type::argument_type argument_type
JFunction1D< JArgument_t, JResult_t > function_type
Definition of zero value for any class.
virtual void do_compile() override
Function compilation.
Template definition of function object interface in one dimension.
Definition: JFunctional.hh:317
Template implementation of function object in one dimension.
virtual result_type evaluate(const argument_type *pX) const override
Function value evaluation.
The template JSinglePointer class can be used to hold a pointer to an object.
virtual result_type evaluate(const argument_type *pX) const override
Function value evaluation.
virtual void do_compile() override
Function compilation.
JArgument< T >::argument_type argument_type
Definition: JClass.hh:82
Template implementation of function object in one dimension returning a constant value.
JFunctionObject1D(typename JLANG::JClass< result_type >::argument_type y)
Constructor.
JArgument_t argument_type
Definition: JFunctional.hh:84
JFunctionObject1D()
Default constructor.
JLANG::JSinglePointer< function_type > function
functional_type::result_type result_type
Definition: JFunctional.hh:324
Interface for binary input.
function_type::result_type result_type
Template implementation of function object in one dimension using an external function.
function_type::result_type result_type
JResult_t result_type
Definition: JFunctional.hh:87
JFunctionObject1D(result_type(*f)(const argument_type))
Constructor.