smooth_linear_spline.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_SMOOTH_LINEAR_SPLINE_HPP_
13 #define ECL_SMOOTH_LINEAR_SPLINE_HPP_
14 
15 /*****************************************************************************
16 ** Includes
17 *****************************************************************************/
18 
19 #include <ecl/config/macros.hpp>
20 #include <ecl/concepts/streams.hpp>
21 #include <ecl/containers/array.hpp>
24 #include "polynomial.hpp"
25 #include "macros.hpp"
26 
27 /*****************************************************************************
28 ** Namespaces
29 *****************************************************************************/
30 
31 namespace ecl {
32 
33 /*****************************************************************************
34 ** Interface [SmoothLinearSpline]
35 *****************************************************************************/
46 public:
77  SmoothLinearSpline(const Array<double>& x_data, const Array<double>& y_data, double a_max) throw (DataException<int>);
78 
79  virtual ~SmoothLinearSpline() {}
80 
90  double operator()(const double &x) const ecl_assert_throw_decl(StandardException);
101  double derivative(const double &x) const ecl_assert_throw_decl(StandardException);
110  double dderivative(const double &x) const ecl_assert_throw_decl(StandardException);
111 
120  const Array<double>& domain() const { return discretised_domain; }
121 
122  /*********************
123  * Static Constructor
124  **********************/
136  static SmoothLinearSpline Interpolation(const Array<double>& x_data, const Array<double>& y_data, double a_max) throw (DataException<int>)
137  {
138  try {
139  return SmoothLinearSpline(x_data, y_data, a_max);
140  } catch ( DataException<int> &e ) {
141  throw DataException<int>(LOC,e);
142  }
143  return SmoothLinearSpline(); // avoid a warning because of the rethrown exception.
144  }
145 
146  /******************************************
147  * Streaming
148  *******************************************/
162  template <typename OutputStream>
163  friend OutputStream& operator << (OutputStream &ostream, const SmoothLinearSpline &smooth_linear_spline);
164 
165 private:
166  Array<double> discretised_domain; // 2*N points (2 end points + 2*(N-1) corner points)
167  Array<LinearFunction> segments; // N linear segments
169 };
170 
171 /*****************************************************************************
172 ** Implementation [SmoothLinearSpline][Streaming]
173 *****************************************************************************/
174 
175 template <typename OutputStream>
176 OutputStream& operator << (OutputStream &ostream, const SmoothLinearSpline &smooth_linear_spline) {
177 
179 
180  ostream << smooth_linear_spline.segments[0] << "\n";
181  for ( unsigned int i = 1; i < smooth_linear_spline.segments.size(); ++i ) {
182  ostream << smooth_linear_spline.corners[i-1] << "\n";
183  ostream << smooth_linear_spline.segments[i] << "\n";
184  }
185  ostream.flush();
186  return ostream;
187 }
188 
189 } // namespace ecl
190 
191 #endif /* ECL_SMOOTH_LINEAR_SPLINE_HPP_ */
Embedded control libraries.
Storage container for a smoothed linear spline interpolation.
#define LOC
OutputStream & operator<<(OutputStream &ostream, const Void void_object)
#define ecl_geometry_PUBLIC
Definition: macros.hpp:37
Representations for polynomial functions.
const Array< double > & domain() const
The discretised domain for this spline.
Array< QuinticPolynomial > corners
#define ecl_assert_throw_decl(exception)
SmoothLinearSpline()
Default constructor.
#define ecl_compile_time_concept_check(Model)
static SmoothLinearSpline Interpolation(const Array< double > &x_data, const Array< double > &y_data, double a_max)
Static construction that interpolates on a set of waypoints.
Array< LinearFunction > segments


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:37