spline_function.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_GEOMETRY_SPLINE_FUNCTION_HPP_
13 #define ECL_GEOMETRY_SPLINE_FUNCTION_HPP_
14 
15 /*****************************************************************************
16 ** Includes
17 *****************************************************************************/
18 
19 #include <ecl/config/macros.hpp>
20 #include <ecl/containers/array.hpp>
22 
23 /*****************************************************************************
24 ** Namespaces
25 *****************************************************************************/
26 
27 namespace ecl {
28 
29 /*****************************************************************************
30 ** Interface [GenericSplineFunction]
31 *****************************************************************************/
39 class ECL_PUBLIC GenericSplineFunction {
40  public:
41  virtual ~GenericSplineFunction() {};
47  virtual double operator()(const double &x) const = 0;
53  virtual double derivative(const double &x) const = 0;
59  virtual double dderivative(const double &x) const = 0;
60 
68  const Array<double,2>& domain() { return time_domain; }
69 
70  protected:
71  Array<double,2> time_domain;
72 };
73 /*****************************************************************************
74 ** Interface [SplineFunction]
75 *****************************************************************************/
87 template <typename Function>
88 class ECL_PUBLIC SplineFunction : public GenericSplineFunction {
89  public:
99  SplineFunction (const double& time_begin, const double& time_end, const Function& f) : function(f) {
100  time_domain << time_begin, time_end;
101  };
102  virtual ~SplineFunction() {};
103 
110  double operator()(const double &x) const {
111  ecl_assert_throw( ( x >= time_domain[0] ) && x <= time_domain[1], StandardException(LOC,OutOfRangeError ) );
112  return function(x);
113  }
114 
121  double derivative(const double &x) const {
122  ecl_assert_throw( ( x >= time_domain[0] ) && x <= time_domain[1], StandardException(LOC,OutOfRangeError ) );
123  return function.derivative(x);
124  }
125 
132  double dderivative(const double &x) const {
133  ecl_assert_throw( ( x >= time_domain[0] ) && x <= time_domain[1], StandardException(LOC,OutOfRangeError ) );
134  return function.dderivative(x);
135  }
136 
137  private:
138  Function function;
139 };
140 
141 }; // namespace ecl
142 
143 
144 #endif /* SPLINE_FUNCTION_HPP_ */
f
void f(int i)
LOC
#define LOC
ecl::StandardException
array.hpp
ecl_assert_throw
#define ecl_assert_throw(expression, exception)
standard_exception.hpp
macros.hpp
ecl::OutOfRangeError
OutOfRangeError
ecl
Embedded control libraries.
ECL_PUBLIC
#define ECL_PUBLIC


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:39