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 *****************************************************************************/
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:
72 };
73 /*****************************************************************************
74 ** Interface [SplineFunction]
75 *****************************************************************************/
87 template <typename Function>
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_ */
Embedded control libraries.
#define LOC
Template wrapper for a generic spline function.
Array< double, 2 > time_domain
#define ecl_assert_throw(expression, exception)
OutOfRangeError
double operator()(const double &x) const
Access the value of the spline function at the specified value.
SplineFunction(const double &time_begin, const double &time_end, const Function &f)
Constructor, copies across an already existing spline function type and wraps it. ...
const Array< double, 2 > & domain()