$search
00001 00008 /***************************************************************************** 00009 ** Ifdefs 00010 *****************************************************************************/ 00011 00012 #ifndef ECL_GEOMETRY_SPLINE_FUNCTION_HPP_ 00013 #define ECL_GEOMETRY_SPLINE_FUNCTION_HPP_ 00014 00015 /***************************************************************************** 00016 ** Includes 00017 *****************************************************************************/ 00018 00019 #include <ecl/config/macros.hpp> 00020 #include <ecl/containers/array.hpp> 00021 #include <ecl/exceptions/standard_exception.hpp> 00022 00023 /***************************************************************************** 00024 ** Namespaces 00025 *****************************************************************************/ 00026 00027 namespace ecl { 00028 00029 /***************************************************************************** 00030 ** Interface [GenericSplineFunction] 00031 *****************************************************************************/ 00039 class ECL_PUBLIC GenericSplineFunction { 00040 public: 00041 virtual ~GenericSplineFunction() {}; 00047 virtual double operator()(const double &x) const = 0; 00053 virtual double derivative(const double &x) const = 0; 00059 virtual double dderivative(const double &x) const = 0; 00060 00068 const Array<double,2>& domain() { return time_domain; } 00069 00070 protected: 00071 Array<double,2> time_domain; 00072 }; 00073 /***************************************************************************** 00074 ** Interface [SplineFunction] 00075 *****************************************************************************/ 00087 template <typename Function> 00088 class ECL_PUBLIC SplineFunction : public GenericSplineFunction { 00089 public: 00099 SplineFunction (const double& time_begin, const double& time_end, const Function& f) : function(f) { 00100 time_domain << time_begin, time_end; 00101 }; 00102 virtual ~SplineFunction() {}; 00103 00110 double operator()(const double &x) const ecl_assert_throw_decl(StandardException) { 00111 ecl_assert_throw( ( x >= time_domain[0] ) && x <= time_domain[1], StandardException(LOC,OutOfRangeError ) ); 00112 return function(x); 00113 } 00114 00121 double derivative(const double &x) const ecl_assert_throw_decl(StandardException) { 00122 ecl_assert_throw( ( x >= time_domain[0] ) && x <= time_domain[1], StandardException(LOC,OutOfRangeError ) ); 00123 return function.derivative(x); 00124 } 00125 00132 double dderivative(const double &x) const ecl_assert_throw_decl(StandardException) { 00133 ecl_assert_throw( ( x >= time_domain[0] ) && x <= time_domain[1], StandardException(LOC,OutOfRangeError ) ); 00134 return function.dderivative(x); 00135 } 00136 00137 private: 00138 Function function; 00139 }; 00140 00141 }; // namespace ecl 00142 00143 00144 #endif /* SPLINE_FUNCTION_HPP_ */