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>
21 #include <ecl/exceptions/standard_exception.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 ecl_assert_throw_decl(StandardException) {
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 ecl_assert_throw_decl(StandardException) {
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 ecl_assert_throw_decl(StandardException) {
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_ */
#define LOC
Stringify the line of code you are at.
#define ecl_assert_throw(expression, exception)
Debug mode throw with a logical condition check.
OutOfRangeError
TFSIMD_FORCE_INLINE const tfScalar & x() const
#define ECL_PUBLIC
#define ecl_assert_throw_decl(exception)
Assure throw exception declaration.


xbot_node
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:28:13